diff --git a/.gitignore b/.gitignore index 96cbdcdb..2ca8f807 100644 --- a/.gitignore +++ b/.gitignore @@ -90,4 +90,7 @@ crashlytics-build.properties # Files generated by documentation tool /Assets/Virtual Agents Framework/Editor/Scripts/Behaviour Tree/obj -/Assets/Virtual Agents Framework/Editor/Scripts/Behaviour Tree/obj.meta \ No newline at end of file +/Assets/Virtual Agents Framework/Editor/Scripts/Behaviour Tree/obj.meta + +# Files generated by spelling error correction +ltex.dictionary.en-US.txt diff --git a/Assets/Editor.meta b/Assets/Editor.meta new file mode 100644 index 00000000..aac36779 --- /dev/null +++ b/Assets/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8012547f31a508249a9f46e3a5776661 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Editor/RWTHColors.colors b/Assets/Editor/RWTHColors.colors new file mode 100644 index 00000000..a9623b92 --- /dev/null +++ b/Assets/Editor/RWTHColors.colors @@ -0,0 +1,39 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &1 +MonoBehaviour: + m_ObjectHideFlags: 52 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 12323, guid: 0000000000000000e000000000000000, type: 0} + m_Name: RWTHColors + m_EditorClassIdentifier: + m_Presets: + - m_Name: + m_Color: {r: 0, g: 0.03137255, b: 0.62352943, a: 1} + - m_Name: + m_Color: {r: 0.5568628, g: 0.7294118, b: 0.8980392, a: 1} + - m_Name: + m_Color: {r: 0.8901961, g: 0, b: 0.4, a: 1} + - m_Name: + m_Color: {r: 1, g: 0.92941177, b: 0, a: 1} + - m_Name: + m_Color: {r: 0, g: 0.38039216, b: 0.39607844, a: 1} + - m_Name: + m_Color: {r: 0, g: 0.59607846, b: 0.6313726, a: 1} + - m_Name: + m_Color: {r: 0.34117648, g: 0.67058825, b: 0.15294118, a: 1} + - m_Name: + m_Color: {r: 0.9647059, g: 0.65882355, b: 0, a: 1} + - m_Name: + m_Color: {r: 0.8, g: 0.02745098, b: 0.11764706, a: 1} + - m_Name: + m_Color: {r: 0.6313726, g: 0.0627451, b: 0.20784314, a: 1} + - m_Name: + m_Color: {r: 0.38039216, g: 0.12941177, b: 0.34509805, a: 1} + - m_Name: + m_Color: {r: 0.47843137, g: 0.43529412, b: 0.6745098, a: 1} diff --git a/Assets/Editor/RWTHColors.colors.meta b/Assets/Editor/RWTHColors.colors.meta new file mode 100644 index 00000000..272774d5 --- /dev/null +++ b/Assets/Editor/RWTHColors.colors.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d8749cf92c7695c439d40fa741be4305 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Virtual Agents Framework/Editor/Scripts/Behaviour Tree.meta b/Assets/Virtual Agents Framework/Editor/Scripts/Behaviour Tree.meta new file mode 100644 index 00000000..61805756 --- /dev/null +++ b/Assets/Virtual Agents Framework/Editor/Scripts/Behaviour Tree.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e4314f6a9c431bd4ab72d83a151444c0 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Virtual Agents Framework/Editor/Scripts/Behaviour Tree/BehaviourTreeEditor.cs b/Assets/Virtual Agents Framework/Editor/Scripts/Behaviour Tree/BehaviourTreeEditor.cs new file mode 100644 index 00000000..286325ed --- /dev/null +++ b/Assets/Virtual Agents Framework/Editor/Scripts/Behaviour Tree/BehaviourTreeEditor.cs @@ -0,0 +1,177 @@ +using i5.VirtualAgents.BehaviourTrees; +using i5.VirtualAgents.BehaviourTrees.Visual; +using UnityEditor; +using UnityEditor.Callbacks; +using UnityEngine; +using UnityEngine.UIElements; + +namespace i5.VirtualAgents.Editor.BehaviourTrees +{ + /// + /// Provides a visual Behaviour Tree Editor. + /// + public class BehaviourTreeEditor : EditorWindow + { + private BehaviourTreeView treeView; + private InspectorView inspectorView; + private Label treeViewOccludeLabel; + private VisualElement occludeLabelParent; + private Button saveButton; + private Button layoutButton; + + [MenuItem("Virtual Agents Framework/Behaviour Tree Editor")] + public static BehaviourTreeEditor ShowWindow() + { + BehaviourTreeEditor window = GetWindow(); + window.titleContent = new GUIContent("Behaviour Tree Editor"); + // Set minimum window size, so that every part of the Editor can be seen + window.minSize = new Vector2(600f, 400f); + return window; + } + + public void CreateGUI() + { + // Each editor window contains a root VisualElement object + VisualElement root = rootVisualElement; + + // Import UXML. The UXML was generated by the Unity UIBuilder and contains which visual elements in which configuration comprise the BehaviourTreeEditor. + var visualTree = AssetDatabase.LoadAssetAtPath("Assets/Virtual Agents Framework/Editor/UI Builder/Behaviour Tree/BehaviourTreeEditor.uxml"); + visualTree.CloneTree(root); + + // A stylesheet can be added to a VisualElement. + // The style will be applied to the VisualElement and all of its children. + var styleSheet = AssetDatabase.LoadAssetAtPath("Assets/Virtual Agents Framework/Editor/UI Builder/Behaviour Tree/BehaviourTreeEditorStyleSheet.uss"); + root.styleSheets.Add(styleSheet); + + // Fetch and initialize objects from window + treeView = root.Query(); + treeView.SetupManipulators(); + inspectorView = root.Query(); + treeView.OnNodeSelect = OnNodeSelectionChanged; + treeViewOccludeLabel = root.Query