diff --git a/Assets/com.fluid.behavior-tree/Editor/BehaviorTree/Printer/BehaviorTreePrinter.cs b/Assets/com.fluid.behavior-tree/Editor/BehaviorTree/Printer/BehaviorTreePrinter.cs index 39e528d7..7aad4a1d 100644 --- a/Assets/com.fluid.behavior-tree/Editor/BehaviorTree/Printer/BehaviorTreePrinter.cs +++ b/Assets/com.fluid.behavior-tree/Editor/BehaviorTree/Printer/BehaviorTreePrinter.cs @@ -8,22 +8,20 @@ public class BehaviorTreePrinter { private readonly Rect _containerSize; private Vector2 _scrollPosition; - + public static StatusIcons StatusIcons { get; private set; } - public static GuiStyleCollection SharedStyles { get; private set; } public BehaviorTreePrinter (IBehaviorTree tree, Vector2 windowSize) { StatusIcons = new StatusIcons(); - SharedStyles = new GuiStyleCollection(); var container = new GraphContainerVertical(); container.SetGlobalPosition(SCROLL_PADDING, SCROLL_PADDING); _root = new VisualTask(tree.Root, container); container.CenterAlignChildren(); - - _containerSize = new Rect(0, 0, - container.Width + SCROLL_PADDING * 2, + + _containerSize = new Rect(0, 0, + container.Width + SCROLL_PADDING * 2, container.Height + SCROLL_PADDING * 2); CenterScrollView(windowSize, container); @@ -37,8 +35,8 @@ private void CenterScrollView (Vector2 windowSize, GraphContainerVertical contai public void Print (Vector2 windowSize) { _scrollPosition = GUI.BeginScrollView( - new Rect(0, 0, windowSize.x, windowSize.y), - _scrollPosition, + new Rect(0, 0, windowSize.x, windowSize.y), + _scrollPosition, _containerSize); _root.Print(); GUI.EndScrollView(); @@ -48,4 +46,4 @@ public void Unbind () { _root.RecursiveTaskUnbind(); } } -} \ No newline at end of file +} diff --git a/Assets/com.fluid.behavior-tree/Editor/BehaviorTree/Printer/Graphics/AssetPath.cs b/Assets/com.fluid.behavior-tree/Editor/BehaviorTree/Printer/Graphics/AssetPath.cs index fb428f0e..01c49dd5 100644 --- a/Assets/com.fluid.behavior-tree/Editor/BehaviorTree/Printer/Graphics/AssetPath.cs +++ b/Assets/com.fluid.behavior-tree/Editor/BehaviorTree/Printer/Graphics/AssetPath.cs @@ -8,6 +8,7 @@ namespace CleverCrow.Fluid.BTs.Trees.Editors { public static class AssetPath { private const string PATH_PROJECT = "Assets/FluidBehaviorTree"; private const string PATH_PACKAGE = "Packages/com.fluid.behavior-tree"; + private const string PATH_PACKAGE2 = "Assets/com.fluid.behavior-tree"; private static string _basePath; @@ -19,6 +20,11 @@ public static string BasePath { _basePath = PATH_PACKAGE; return _basePath; } + + if (AssetDatabase.IsValidFolder(PATH_PACKAGE2)) { + _basePath = PATH_PACKAGE2; + return _basePath; + } if (AssetDatabase.IsValidFolder(PATH_PROJECT)) { _basePath = PATH_PROJECT; diff --git a/Assets/com.fluid.behavior-tree/Editor/BehaviorTree/Printer/Graphics/DsplaySettings.cs b/Assets/com.fluid.behavior-tree/Editor/BehaviorTree/Printer/Graphics/DsplaySettings.cs new file mode 100644 index 00000000..d0984ce4 --- /dev/null +++ b/Assets/com.fluid.behavior-tree/Editor/BehaviorTree/Printer/Graphics/DsplaySettings.cs @@ -0,0 +1,36 @@ +using System.Linq; +using UnityEngine; + +/// +/// Display settings of the behaviour tree window +/// +public class DisplaySettings { + public static Color lightModeActive { get; } = new Color(0.39f, 0.78f, 0.39f); + public static Color lightModeInactive { get; } = new Color(0.65f, 0.65f, 0.65f); + public static Color lightModeActiveText { get; } = Color.white; + public static Color lightModeInactiveText { get; } = Color.black; + public static Color lightModeActiveMainIcon { get; } = new Color(1, 1, 1, 1f); + public static Color lightModeInactiveMainIcon { get; } = new Color(1, 1, 1, 0.3f); + + public static Color darkModeActive { get; } = Color.white; + public static Color darkModeInactive { get; } = new Color(0f, 0f, 0f, 1f); + public static Color darkModeActiveText { get; } = Color.white; + public static Color darkModeInactiveText { get; } = Color.grey; + public static Color darkModeActiveMainIcon { get; } = new Color(1, 1, 1, 1f); + public static Color darkModeInactiveMainIcon { get; } = new Color(1, 1, 1, 0.3f); + + public static GUIStyle taskFontFormat { get; } = new GUIStyle(GUI.skin.label) { + fontSize = 9, + alignment = TextAnchor.LowerCenter, + wordWrap = true, + padding = new RectOffset(3, 3, 3, 3), + }; + + public static GUIStyle lightModeBoxStyle = new GUIStyle(GUI.skin.box) { + // Perhaps make it better one day + }; + + public static GUIStyle darkModeBoxStyle = new GUIStyle(GUI.skin.box) { + // Perhaps make it better one day + }; +} diff --git a/Assets/com.fluid.behavior-tree/Editor/BehaviorTree/Printer/Graphics/DsplaySettings.cs.meta b/Assets/com.fluid.behavior-tree/Editor/BehaviorTree/Printer/Graphics/DsplaySettings.cs.meta new file mode 100644 index 00000000..0b8a2ef9 --- /dev/null +++ b/Assets/com.fluid.behavior-tree/Editor/BehaviorTree/Printer/Graphics/DsplaySettings.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e1cb1344c78dc42f0b428e2813123590 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/com.fluid.behavior-tree/Editor/BehaviorTree/Printer/Graphics/NodeBoxStyle.cs b/Assets/com.fluid.behavior-tree/Editor/BehaviorTree/Printer/Graphics/NodeBoxStyle.cs deleted file mode 100644 index 25bd4040..00000000 --- a/Assets/com.fluid.behavior-tree/Editor/BehaviorTree/Printer/Graphics/NodeBoxStyle.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.Linq; -using UnityEngine; - -namespace CleverCrow.Fluid.BTs.Trees.Editors { - public class NodeBoxStyle { - public GUIStyle Style { get; } - - public NodeBoxStyle (Color32 border, Color background) { - var texture = CreateTexture(19, 19, border); - texture.SetPixels(1, 1, 17, 17, - Enumerable.Repeat(background, 17 * 17).ToArray()); - texture.Apply(); - - Style = new GUIStyle(GUI.skin.box) { - border = new RectOffset(1, 1, 1, 1), - normal = { - background = texture, - }, - }; - } - - private static Texture2D CreateTexture (int width, int height, Color color) { - var texture = new Texture2D(width, height, TextureFormat.ARGB32, false); - texture.SetPixels(Enumerable.Repeat(color, width * height).ToArray()); - texture.Apply(); - - return texture; - } - } -} \ No newline at end of file diff --git a/Assets/com.fluid.behavior-tree/Editor/BehaviorTree/Printer/Graphics/NodeBoxStyle.cs.meta b/Assets/com.fluid.behavior-tree/Editor/BehaviorTree/Printer/Graphics/NodeBoxStyle.cs.meta deleted file mode 100644 index be4580d9..00000000 --- a/Assets/com.fluid.behavior-tree/Editor/BehaviorTree/Printer/Graphics/NodeBoxStyle.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: fb7e76da847c4756b7091dde1962020d -timeCreated: 1560027484 \ No newline at end of file diff --git a/Assets/com.fluid.behavior-tree/Editor/BehaviorTree/Printer/Graphics/NodeBoxStyleCollection.cs b/Assets/com.fluid.behavior-tree/Editor/BehaviorTree/Printer/Graphics/NodeBoxStyleCollection.cs deleted file mode 100644 index d509fb21..00000000 --- a/Assets/com.fluid.behavior-tree/Editor/BehaviorTree/Printer/Graphics/NodeBoxStyleCollection.cs +++ /dev/null @@ -1,18 +0,0 @@ -using UnityEngine; - -namespace CleverCrow.Fluid.BTs.Trees.Editors { - public class GuiStyleCollection { - public NodeBoxStyle BoxActive { get; } = new NodeBoxStyle(Color.gray, Color.white); - - public NodeBoxStyle BoxInactive { get; } = new NodeBoxStyle( - new Color32(150, 150, 150, 255), - new Color32(208, 208, 208, 255)); - - public GUIStyle Title { get; } = new GUIStyle(GUI.skin.label) { - fontSize = 9, - alignment = TextAnchor.LowerCenter, - wordWrap = true, - padding = new RectOffset(3, 3, 3, 3), - }; - } -} diff --git a/Assets/com.fluid.behavior-tree/Editor/BehaviorTree/Printer/Graphics/NodeBoxStyleCollection.cs.meta b/Assets/com.fluid.behavior-tree/Editor/BehaviorTree/Printer/Graphics/NodeBoxStyleCollection.cs.meta deleted file mode 100644 index 4dcfbac8..00000000 --- a/Assets/com.fluid.behavior-tree/Editor/BehaviorTree/Printer/Graphics/NodeBoxStyleCollection.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: b010848be7db435a93eb237039e42d04 -timeCreated: 1560026196 \ No newline at end of file diff --git a/Assets/com.fluid.behavior-tree/Editor/BehaviorTree/Printer/Graphics/NodeFaders.cs b/Assets/com.fluid.behavior-tree/Editor/BehaviorTree/Printer/Graphics/NodeFaders.cs index 0514ffc6..8ff3c252 100644 --- a/Assets/com.fluid.behavior-tree/Editor/BehaviorTree/Printer/Graphics/NodeFaders.cs +++ b/Assets/com.fluid.behavior-tree/Editor/BehaviorTree/Printer/Graphics/NodeFaders.cs @@ -1,15 +1,38 @@ using UnityEngine; +using UnityEditor; namespace CleverCrow.Fluid.BTs.Trees.Editors { public class NodeFaders { - public ColorFader BackgroundFader { get; } = new ColorFader( - new Color(0.65f, 0.65f, 0.65f), new Color(0.39f, 0.78f, 0.39f)); - - public ColorFader TextFader { get; } = new ColorFader( - Color.white, Color.black); - - public ColorFader MainIconFader { get; } = new ColorFader( - new Color(1, 1, 1, 0.3f), new Color(1, 1, 1, 1f)); + public ColorFader BackgroundFader { get; } + + public ColorFader TextFader { get; } + + public ColorFader MainIconFader { get; } + + public NodeFaders() { + // If in dark mode choose dark mode + if (EditorGUIUtility.isProSkin){ + BackgroundFader = new ColorFader( + DisplaySettings.darkModeInactive, + DisplaySettings.darkModeActive); + TextFader = new ColorFader( + DisplaySettings.darkModeInactiveText, + DisplaySettings.darkModeActiveText); + MainIconFader = new ColorFader( + DisplaySettings.darkModeInactiveMainIcon, + DisplaySettings.darkModeActiveMainIcon); + }else { + BackgroundFader = new ColorFader( + DisplaySettings.lightModeInactive, + DisplaySettings.lightModeActive); + TextFader = new ColorFader( + DisplaySettings.lightModeInactiveText, + DisplaySettings.lightModeActiveText); + MainIconFader = new ColorFader( + DisplaySettings.lightModeInactiveMainIcon, + DisplaySettings.lightModeActiveMainIcon); + } + } public void Update (bool active) { BackgroundFader.Update(active); @@ -17,4 +40,4 @@ public void Update (bool active) { MainIconFader.Update(active); } } -} \ No newline at end of file +} diff --git a/Assets/com.fluid.behavior-tree/Editor/BehaviorTree/Printer/NodePrintController.cs b/Assets/com.fluid.behavior-tree/Editor/BehaviorTree/Printer/NodePrintController.cs index 9d3a7031..4a6c4cb0 100644 --- a/Assets/com.fluid.behavior-tree/Editor/BehaviorTree/Printer/NodePrintController.cs +++ b/Assets/com.fluid.behavior-tree/Editor/BehaviorTree/Printer/NodePrintController.cs @@ -1,6 +1,7 @@ using System.Linq; using CleverCrow.Fluid.BTs.TaskParents; using UnityEngine; +using UnityEditor; namespace CleverCrow.Fluid.BTs.Trees.Editors { public class NodePrintController { @@ -15,8 +16,6 @@ public class NodePrintController { private Texture2D _verticalBottom; private Texture2D _verticalTop; - private static GuiStyleCollection Styles => BehaviorTreePrinter.SharedStyles; - public NodePrintController (VisualTask node) { _node = node; _box = node.Box; @@ -40,25 +39,38 @@ private void PaintBody () { var prevBackgroundColor = GUI.backgroundColor; var rect = new Rect( - _box.GlobalPositionX + _box.PaddingX, + _box.GlobalPositionX + _box.PaddingX, _box.GlobalPositionY + _box.PaddingY, - _box.Width - _box.PaddingX, + _box.Width - _box.PaddingX, _box.Height - _box.PaddingY); if (_node.Task.HasBeenActive) { GUI.backgroundColor = _faders.BackgroundFader.CurrentColor; - GUI.Box(rect, GUIContent.none, Styles.BoxActive.Style); + + if (EditorGUIUtility.isProSkin) { + GUI.Box(rect, GUIContent.none, new GUIStyle(DisplaySettings.darkModeBoxStyle)); + } + else { + GUI.Box(rect, GUIContent.none, new GUIStyle(DisplaySettings.lightModeBoxStyle)); + } + GUI.backgroundColor = prevBackgroundColor; - PrintLastStatus(rect); - } else { - GUI.Box(rect, GUIContent.none, Styles.BoxInactive.Style); } - + else { + if (EditorGUIUtility.isProSkin) { + GUI.Box(rect, GUIContent.none, new GUIStyle(DisplaySettings.darkModeBoxStyle)); + } + else { + GUI.Box(rect, GUIContent.none, new GUIStyle(DisplaySettings.lightModeBoxStyle)); + } + } + PrintIcon(); - Styles.Title.normal.textColor = _faders.TextFader.CurrentColor; - GUI.Label(rect, _node.Task.Name, Styles.Title); + var textFormat = DisplaySettings.taskFontFormat; + textFormat.normal.textColor = _faders.TextFader.CurrentColor; + GUI.Label(rect, _node.Task.Name, textFormat); } private void PrintLastStatus (Rect rect) {