diff --git a/License.meta b/License.meta new file mode 100644 index 0000000..171d1d8 --- /dev/null +++ b/License.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 82765577abc7c5346892518f8e696f79 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Sample.meta b/Sample.meta new file mode 100644 index 0000000..053ada4 --- /dev/null +++ b/Sample.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 18f38c39496afae47ab40fb512c3ce7c +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Sample/Editor.meta b/Sample/Editor.meta new file mode 100644 index 0000000..8c4183f --- /dev/null +++ b/Sample/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: dc673adb081e1f841bdf4998bdb7b50a +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Sample/Editor/HelloWorld.asset b/Sample/Editor/HelloWorld.asset new file mode 100644 index 0000000..8dfc869 --- /dev/null +++ b/Sample/Editor/HelloWorld.asset @@ -0,0 +1,27 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + 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: 11500000, guid: cde084f079a7426daa86ed86cb80ed1b, type: 3} + m_Name: HelloWorld + m_EditorClassIdentifier: + nodeData: + rid: -2 + nodePos: + serializedVersion: 2 + x: 0 + y: 0 + width: 0 + height: 0 + references: + version: 2 + RefIds: + - rid: -2 + type: {class: , ns: , asm: } diff --git a/Sample/Editor/HelloWorld.asset.meta b/Sample/Editor/HelloWorld.asset.meta new file mode 100644 index 0000000..0ec0efa --- /dev/null +++ b/Sample/Editor/HelloWorld.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ad64ccb31efdc9c4082380856cd58efc +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Sample/Editor/HelloWorld.cs b/Sample/Editor/HelloWorld.cs new file mode 100644 index 0000000..9de7b9e --- /dev/null +++ b/Sample/Editor/HelloWorld.cs @@ -0,0 +1,10 @@ +using TNode.Editor; +using UnityEditor; +using UnityEditor.Callbacks; +using UnityEditor.Experimental.GraphView; +using UnityEngine; +using UnityEngine.UIElements; + +public class HelloWorld : GraphEditor{ + +} \ No newline at end of file diff --git a/Sample/Editor/HelloWorld.cs.meta b/Sample/Editor/HelloWorld.cs.meta new file mode 100644 index 0000000..f68d71c --- /dev/null +++ b/Sample/Editor/HelloWorld.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 7b39119946f2f83458e3c2bafb200552 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: + - nodeEditorData: {fileID: 11400000, guid: ad64ccb31efdc9c4082380856cd58efc, type: 2} + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Sample/Editor/HelloWorldGraph.cs b/Sample/Editor/HelloWorldGraph.cs new file mode 100644 index 0000000..bc22163 --- /dev/null +++ b/Sample/Editor/HelloWorldGraph.cs @@ -0,0 +1,4 @@ +using TNode.Models; +public class HelloWorldGraph : GraphData{ + +} \ No newline at end of file diff --git a/Sample/Editor/HelloWorldGraph.cs.meta b/Sample/Editor/HelloWorldGraph.cs.meta new file mode 100644 index 0000000..982b74d --- /dev/null +++ b/Sample/Editor/HelloWorldGraph.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8b641f4bc28454e4aa2c5ddc629b07c2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/TNode/Editor/Resources/ScriptTemplates/NewGraph.cs.txt b/TNode/Editor/Resources/ScriptTemplates/NewGraph.cs.txt index e9d1767..fdccd12 100644 --- a/TNode/Editor/Resources/ScriptTemplates/NewGraph.cs.txt +++ b/TNode/Editor/Resources/ScriptTemplates/NewGraph.cs.txt @@ -1,4 +1,8 @@ using TNode.Models; +using UnityEngine; +using UnityEditor; +[CreateAssetMenu(fileName = "New $GraphClassName$", menuName = "TNode/$GraphClassName$")] +[Serializable] public class $GraphClassName$ : GraphData{ } \ No newline at end of file diff --git a/TNode/Editor/Tools/GraphEditorCreator/GraphEditorCreator.cs b/TNode/Editor/Tools/GraphEditorCreator/GraphEditorCreator.cs new file mode 100644 index 0000000..19af845 --- /dev/null +++ b/TNode/Editor/Tools/GraphEditorCreator/GraphEditorCreator.cs @@ -0,0 +1,137 @@ +using System.IO; +using TNode.Editor.Model; +using UnityEditor; +using UnityEngine; +using UnityEngine.UIElements; + +//add an attribute right click asset panel and select "TNode/Create/Create New Graph Editor" to call this editor + + +namespace TNode.Editor.Tools.GraphEditorCreator{ + + public class GraphEditorCreator : EditorWindow + { + [SerializeField] + private VisualTreeAsset m_VisualTreeAsset = default; + + [MenuItem("Assets/Create/TNode/Create New Graph Editor")] + [MenuItem("TNode/Create New Graph Editor")] + public static void ShowExample() + { + GraphEditorCreator wnd = GetWindow(); + wnd.titleContent = new GUIContent("GraphEditorCreator"); + //Set position to the center of the screen + wnd.position = new(Screen.width / 2, Screen.height / 2, 500, 300); + //set this window non resizable + wnd.minSize = new Vector2(500, 300); + wnd.maxSize = new Vector2(500, 300); + + } + + public void CreateGUI() + { + // Each editor window contains a root VisualElement object + VisualElement root = rootVisualElement; + + // VisualElements objects can contain other VisualElement following a tree hierarchy. + VisualElement label = new Label("Hello World! From C#"); + root.Add(label); + + // Instantiate UXML + VisualElement labelFromUXML = m_VisualTreeAsset.Instantiate(); + root.Add(labelFromUXML); + + //Register a callback when Create Button is clicked + Button createButton = root.Q