From 1b030c7cd427dff5c5a98a07dfc3a8652496f49d Mon Sep 17 00:00:00 2001 From: taoria <445625470@qq.com> Date: Sat, 16 Jul 2022 12:14:57 +0800 Subject: [PATCH] fix: daily commit --- Resources.meta | 8 - ...Newtonsoft.Json-for-Unity.Converters.asset | 162 ------------------ ...nsoft.Json-for-Unity.Converters.asset.meta | 8 - Sample.meta | 8 - Sample/MathGraph.meta | 8 - Sample/MathGraph/Editor.meta | 8 - Sample/MathGraph/Editor/MathEditor.cs | 22 --- Sample/MathGraph/Editor/MathEditor.cs.meta | 14 -- Sample/MathGraph/Editor/MathGraphView.cs | 9 - Sample/MathGraph/Editor/MathGraphView.cs.meta | 11 -- .../Editor/NodeAttribute Editor Config.asset | 15 -- .../NodeAttribute Editor Config.asset.meta | 8 - Sample/MathGraph/MathGraph.cs | 10 -- Sample/MathGraph/MathGraph.cs.meta | 11 -- Sample/MathGraph/New MathGraph.asset | 23 --- Sample/MathGraph/New MathGraph.asset.meta | 8 - Sample/TestExposedReference.cs | 10 -- Sample/TestExposedReference.cs.meta | 3 - TNodeCore/Editor/IGraphEditor.cs | 8 + TNodeCore/Editor/IGraphEditor.cs.meta | 3 + .../NodeGraphView/IBaseDataGraphView.cs | 5 +- .../Editor/Serialization/NodeDataWrapper.cs | 76 ++++---- TNodeGraphViewImpl/Editor/GraphEditor.cs | 75 ++++++-- .../Editor/NodeGraphView/DataGraphView.cs | 11 +- 24 files changed, 122 insertions(+), 402 deletions(-) delete mode 100644 Resources.meta delete mode 100644 Resources/Newtonsoft.Json-for-Unity.Converters.asset delete mode 100644 Resources/Newtonsoft.Json-for-Unity.Converters.asset.meta delete mode 100644 Sample.meta delete mode 100644 Sample/MathGraph.meta delete mode 100644 Sample/MathGraph/Editor.meta delete mode 100644 Sample/MathGraph/Editor/MathEditor.cs delete mode 100644 Sample/MathGraph/Editor/MathEditor.cs.meta delete mode 100644 Sample/MathGraph/Editor/MathGraphView.cs delete mode 100644 Sample/MathGraph/Editor/MathGraphView.cs.meta delete mode 100644 Sample/MathGraph/Editor/NodeAttribute Editor Config.asset delete mode 100644 Sample/MathGraph/Editor/NodeAttribute Editor Config.asset.meta delete mode 100644 Sample/MathGraph/MathGraph.cs delete mode 100644 Sample/MathGraph/MathGraph.cs.meta delete mode 100644 Sample/MathGraph/New MathGraph.asset delete mode 100644 Sample/MathGraph/New MathGraph.asset.meta delete mode 100644 Sample/TestExposedReference.cs delete mode 100644 Sample/TestExposedReference.cs.meta create mode 100644 TNodeCore/Editor/IGraphEditor.cs create mode 100644 TNodeCore/Editor/IGraphEditor.cs.meta diff --git a/Resources.meta b/Resources.meta deleted file mode 100644 index d428cde..0000000 --- a/Resources.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 630fb8569cca3804a80f2fb55f7890f2 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Resources/Newtonsoft.Json-for-Unity.Converters.asset b/Resources/Newtonsoft.Json-for-Unity.Converters.asset deleted file mode 100644 index b01ce28..0000000 --- a/Resources/Newtonsoft.Json-for-Unity.Converters.asset +++ /dev/null @@ -1,162 +0,0 @@ -%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: ce56e4dbb13e1644aa983b6dd170e4a7, type: 3} - m_Name: Newtonsoft.Json-for-Unity.Converters - m_EditorClassIdentifier: - useUnityContractResolver: 1 - useAllOutsideConverters: 0 - outsideConverters: - - enabled: 0 - converterName: TNode.JsonSerialize.NodeDataConverter - settings: [] - - enabled: 0 - converterName: TNode.JsonSerialize.UnityObjectConverter - settings: [] - - enabled: 0 - converterName: TNode.JsonSerialize.Vector3Converter - settings: [] - useAllUnityConverters: 1 - unityConverters: - - enabled: 1 - converterName: Newtonsoft.Json.UnityConverters.AI.NavMesh.NavMeshQueryFilterConverter - settings: [] - - enabled: 1 - converterName: Newtonsoft.Json.UnityConverters.AI.NavMesh.NavMeshTriangulationConverter - settings: [] - - enabled: 1 - converterName: Newtonsoft.Json.UnityConverters.Camera.CullingGroupEventConverter - settings: [] - - enabled: 1 - converterName: Newtonsoft.Json.UnityConverters.Geometry.BoundsConverter - settings: [] - - enabled: 1 - converterName: Newtonsoft.Json.UnityConverters.Geometry.BoundsIntConverter - settings: [] - - enabled: 1 - converterName: Newtonsoft.Json.UnityConverters.Geometry.PlaneConverter - settings: [] - - enabled: 1 - converterName: Newtonsoft.Json.UnityConverters.Geometry.RectConverter - settings: [] - - enabled: 1 - converterName: Newtonsoft.Json.UnityConverters.Geometry.RectIntConverter - settings: [] - - enabled: 1 - converterName: Newtonsoft.Json.UnityConverters.Geometry.RectOffsetConverter - settings: [] - - enabled: 1 - converterName: Newtonsoft.Json.UnityConverters.Hashing.Hash128Converter - settings: [] - - enabled: 1 - converterName: Newtonsoft.Json.UnityConverters.Math.Color32Converter - settings: [] - - enabled: 1 - converterName: Newtonsoft.Json.UnityConverters.Math.ColorConverter - settings: [] - - enabled: 1 - converterName: Newtonsoft.Json.UnityConverters.Math.Matrix4x4Converter - settings: [] - - enabled: 1 - converterName: Newtonsoft.Json.UnityConverters.Math.QuaternionConverter - settings: [] - - enabled: 1 - converterName: Newtonsoft.Json.UnityConverters.Math.SphericalHarmonicsL2Converter - settings: [] - - enabled: 1 - converterName: Newtonsoft.Json.UnityConverters.Math.Vector2Converter - settings: [] - - enabled: 1 - converterName: Newtonsoft.Json.UnityConverters.Math.Vector2IntConverter - settings: [] - - enabled: 1 - converterName: Newtonsoft.Json.UnityConverters.Math.Vector3Converter - settings: [] - - enabled: 1 - converterName: Newtonsoft.Json.UnityConverters.Math.Vector3IntConverter - settings: [] - - enabled: 1 - converterName: Newtonsoft.Json.UnityConverters.Math.Vector4Converter - settings: [] - - enabled: 1 - converterName: Newtonsoft.Json.UnityConverters.NativeArray.NativeArrayConverter - settings: [] - - enabled: 1 - converterName: Newtonsoft.Json.UnityConverters.Physics.JointDriveConverter - settings: [] - - enabled: 1 - converterName: Newtonsoft.Json.UnityConverters.Physics.JointLimitsConverter - settings: [] - - enabled: 1 - converterName: Newtonsoft.Json.UnityConverters.Physics.SoftJointLimitConverter - settings: [] - - enabled: 1 - converterName: Newtonsoft.Json.UnityConverters.Physics2D.ColliderDistance2DConverter - settings: [] - - enabled: 1 - converterName: Newtonsoft.Json.UnityConverters.Physics2D.ContactFilter2DConverter - settings: [] - - enabled: 1 - converterName: Newtonsoft.Json.UnityConverters.Random.RandomStateConverter - settings: [] - - enabled: 1 - converterName: Newtonsoft.Json.UnityConverters.Scripting.LayerMaskConverter - settings: [] - - enabled: 1 - converterName: Newtonsoft.Json.UnityConverters.Scripting.RangeIntConverter - settings: [] - useAllJsonNetConverters: 1 - jsonNetConverters: - - enabled: 1 - converterName: Newtonsoft.Json.Converters.StringEnumConverter - settings: [] - - enabled: 1 - converterName: Newtonsoft.Json.Converters.VersionConverter - settings: [] - - enabled: 0 - converterName: Newtonsoft.Json.Converters.BinaryConverter - settings: [] - - enabled: 0 - converterName: Newtonsoft.Json.Converters.BsonObjectIdConverter - settings: [] - - enabled: 0 - converterName: Newtonsoft.Json.Converters.DataSetConverter - settings: [] - - enabled: 0 - converterName: Newtonsoft.Json.Converters.DataTableConverter - settings: [] - - enabled: 0 - converterName: Newtonsoft.Json.Converters.DiscriminatedUnionConverter - settings: [] - - enabled: 0 - converterName: Newtonsoft.Json.Converters.EntityKeyMemberConverter - settings: [] - - enabled: 0 - converterName: Newtonsoft.Json.Converters.ExpandoObjectConverter - settings: [] - - enabled: 0 - converterName: Newtonsoft.Json.Converters.IsoDateTimeConverter - settings: [] - - enabled: 0 - converterName: Newtonsoft.Json.Converters.JavaScriptDateTimeConverter - settings: [] - - enabled: 0 - converterName: Newtonsoft.Json.Converters.KeyValuePairConverter - settings: [] - - enabled: 0 - converterName: Newtonsoft.Json.Converters.RegexConverter - settings: [] - - enabled: 0 - converterName: Newtonsoft.Json.Converters.UnixDateTimeConverter - settings: [] - - enabled: 0 - converterName: Newtonsoft.Json.Converters.XmlNodeConverter - settings: [] diff --git a/Resources/Newtonsoft.Json-for-Unity.Converters.asset.meta b/Resources/Newtonsoft.Json-for-Unity.Converters.asset.meta deleted file mode 100644 index ec4e066..0000000 --- a/Resources/Newtonsoft.Json-for-Unity.Converters.asset.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 466d3febdbd656c4f9728b1116b1564f -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 11400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/Sample.meta b/Sample.meta deleted file mode 100644 index 053ada4..0000000 --- a/Sample.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 18f38c39496afae47ab40fb512c3ce7c -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Sample/MathGraph.meta b/Sample/MathGraph.meta deleted file mode 100644 index 911ec5f..0000000 --- a/Sample/MathGraph.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 23ebabfc8f40d2c4689dc4ec9a5786d5 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Sample/MathGraph/Editor.meta b/Sample/MathGraph/Editor.meta deleted file mode 100644 index 1a654ad..0000000 --- a/Sample/MathGraph/Editor.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 73ee98eea19fa9b42b9c7990a8161d56 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Sample/MathGraph/Editor/MathEditor.cs b/Sample/MathGraph/Editor/MathEditor.cs deleted file mode 100644 index a5bb700..0000000 --- a/Sample/MathGraph/Editor/MathEditor.cs +++ /dev/null @@ -1,22 +0,0 @@ -using TNode.Editor; -using UnityEditor; -using UnityEditor.Callbacks; -using UnityEditor.Experimental.GraphView; -using UnityEngine; -using UnityEngine.UIElements; -using System; -public class MathEditor : GraphEditor{ - [OnOpenAsset] - public static bool OnOpenAsset(int instanceID, int line){ - var graph = EditorUtility.InstanceIDToObject(instanceID) as MathGraph; - if (graph != null) - { - var wnd = GetWindow(); - wnd.titleContent = new GUIContent("MathGraph Editor"); - wnd.CreateGUI(); - wnd.GraphView.Data = graph; - return true; - } - return false; - } -} \ No newline at end of file diff --git a/Sample/MathGraph/Editor/MathEditor.cs.meta b/Sample/MathGraph/Editor/MathEditor.cs.meta deleted file mode 100644 index 7b70665..0000000 --- a/Sample/MathGraph/Editor/MathEditor.cs.meta +++ /dev/null @@ -1,14 +0,0 @@ -fileFormatVersion: 2 -guid: c9041cb574597424fa4124edc3f99af1 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: - - m_ViewDataDictionary: {instanceID: 0} - - mVisualTreeAsset: {fileID: 9197481963319205126, guid: b67f6dcbe2361b649ad2b7845207321b, type: 3} - - graphEditorData: {fileID: 11400000, guid: f582a62cc8e00144f97b4dff1f9ba8cc, type: 2} - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Sample/MathGraph/Editor/MathGraphView.cs b/Sample/MathGraph/Editor/MathGraphView.cs deleted file mode 100644 index 2e366ef..0000000 --- a/Sample/MathGraph/Editor/MathGraphView.cs +++ /dev/null @@ -1,9 +0,0 @@ -using TNodeCore.Attribute; -using TNodeGraphViewImpl.Editor.NodeGraphView; - -[ViewComponent] -public class MathGraphView : BaseDataGraphView{ - - - -} \ No newline at end of file diff --git a/Sample/MathGraph/Editor/MathGraphView.cs.meta b/Sample/MathGraph/Editor/MathGraphView.cs.meta deleted file mode 100644 index c7e283a..0000000 --- a/Sample/MathGraph/Editor/MathGraphView.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 7f4d84b648626d24eb29bfeb81c85e3f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Sample/MathGraph/Editor/NodeAttribute Editor Config.asset b/Sample/MathGraph/Editor/NodeAttribute Editor Config.asset deleted file mode 100644 index 4445e6d..0000000 --- a/Sample/MathGraph/Editor/NodeAttribute Editor Config.asset +++ /dev/null @@ -1,15 +0,0 @@ -%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: 99ad0af56b40495cb6bd6165e652266c, type: 3} - m_Name: NodeAttribute Editor Config - m_EditorClassIdentifier: - nodesData: [] diff --git a/Sample/MathGraph/Editor/NodeAttribute Editor Config.asset.meta b/Sample/MathGraph/Editor/NodeAttribute Editor Config.asset.meta deleted file mode 100644 index f33c3eb..0000000 --- a/Sample/MathGraph/Editor/NodeAttribute Editor Config.asset.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: f582a62cc8e00144f97b4dff1f9ba8cc -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 11400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/Sample/MathGraph/MathGraph.cs b/Sample/MathGraph/MathGraph.cs deleted file mode 100644 index d480670..0000000 --- a/Sample/MathGraph/MathGraph.cs +++ /dev/null @@ -1,10 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System; -using TNodeCore.Models; - -[CreateAssetMenu(fileName = "New MathGraph", menuName = "TNode/MathGraph")] -[Serializable] -public class MathGraph : GraphData{ - -} \ No newline at end of file diff --git a/Sample/MathGraph/MathGraph.cs.meta b/Sample/MathGraph/MathGraph.cs.meta deleted file mode 100644 index 1420f5b..0000000 --- a/Sample/MathGraph/MathGraph.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 73baeb2c71a23da4ca06e3e3e52d5a78 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Sample/MathGraph/New MathGraph.asset b/Sample/MathGraph/New MathGraph.asset deleted file mode 100644 index 154660b..0000000 --- a/Sample/MathGraph/New MathGraph.asset +++ /dev/null @@ -1,23 +0,0 @@ -%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: 73baeb2c71a23da4ca06e3e3e52d5a78, type: 3} - m_Name: New MathGraph - m_EditorClassIdentifier: - nodes: [] - nodeLinks: [] - entryNode: - rid: -2 - references: - version: 2 - RefIds: - - rid: -2 - type: {class: , ns: , asm: } diff --git a/Sample/MathGraph/New MathGraph.asset.meta b/Sample/MathGraph/New MathGraph.asset.meta deleted file mode 100644 index 041e2b1..0000000 --- a/Sample/MathGraph/New MathGraph.asset.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 4b23c513fb78ea44b8a11a0bf7c8479e -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 11400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/Sample/TestExposedReference.cs b/Sample/TestExposedReference.cs deleted file mode 100644 index a44add9..0000000 --- a/Sample/TestExposedReference.cs +++ /dev/null @@ -1,10 +0,0 @@ -using UnityEngine; - -namespace Sample{ - // Create at Asset/Test - [CreateAssetMenu(fileName = "NewData", menuName = "Test/Data", order = 1)] - public class TestExposedReference:ScriptableObject{ - public ExposedReference camera; - public ExposedReference go; - } -} \ No newline at end of file diff --git a/Sample/TestExposedReference.cs.meta b/Sample/TestExposedReference.cs.meta deleted file mode 100644 index f6c4b0e..0000000 --- a/Sample/TestExposedReference.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: fed858872d394fb8896d48178f8a7d78 -timeCreated: 1657862979 \ No newline at end of file diff --git a/TNodeCore/Editor/IGraphEditor.cs b/TNodeCore/Editor/IGraphEditor.cs new file mode 100644 index 0000000..2426868 --- /dev/null +++ b/TNodeCore/Editor/IGraphEditor.cs @@ -0,0 +1,8 @@ +using TNodeCore.Editor.NodeGraphView; + +namespace TNodeCore.Editor{ + public interface IGraphEditor{ + public void SetGraphView(IBaseDataGraphView graphView); + public IBaseDataGraphView GetGraphView(); + } +} \ No newline at end of file diff --git a/TNodeCore/Editor/IGraphEditor.cs.meta b/TNodeCore/Editor/IGraphEditor.cs.meta new file mode 100644 index 0000000..d22ea95 --- /dev/null +++ b/TNodeCore/Editor/IGraphEditor.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: d84e826fe49d4314b8cc1241faf38fd9 +timeCreated: 1657944822 \ No newline at end of file diff --git a/TNodeCore/Editor/NodeGraphView/IBaseDataGraphView.cs b/TNodeCore/Editor/NodeGraphView/IBaseDataGraphView.cs index e30b7ca..bd13be7 100644 --- a/TNodeCore/Editor/NodeGraphView/IBaseDataGraphView.cs +++ b/TNodeCore/Editor/NodeGraphView/IBaseDataGraphView.cs @@ -9,7 +9,8 @@ namespace TNodeCore.Editor.NodeGraphView{ public void CreateBlackboard(); public GraphData GetGraphData(); public BlackboardData GetBlackboardData(); - - + + + void SetGraphData(GraphData graph); } } \ No newline at end of file diff --git a/TNodeCore/Editor/Serialization/NodeDataWrapper.cs b/TNodeCore/Editor/Serialization/NodeDataWrapper.cs index 772e9a8..5d1846e 100644 --- a/TNodeCore/Editor/Serialization/NodeDataWrapper.cs +++ b/TNodeCore/Editor/Serialization/NodeDataWrapper.cs @@ -4,46 +4,46 @@ using TNodeCore.Models; using UnityEngine; namespace TNodeCore.Editor.Serialization{ - [Obsolete] - public class NodeDataWrapper : ScriptableObject where T : NodeData{ - public T Data; - private static readonly Dictionary> Cache = new (); - public event Action> OnValueChanged; - public static NodeDataWrapper Get(T data){ - if(Cache.ContainsKey(data)){ - return Cache[data]; - } - var wrapper = ScriptableObject.CreateInstance>(); - Cache.Add(data,wrapper); - return wrapper; - } - public NodeDataWrapper(T data){ - this.Data = data; - } - - public void SetValue(string path, object value){ - var fieldInfo = Data.GetType().GetField(path); - fieldInfo.SetValue(Data,value); - OnValueChanged?.Invoke(this); - } - public object GetValue(string path){ - var fieldInfo = Data.GetType().GetField(path); - return fieldInfo.GetValue(Data); - } - public static implicit operator T(NodeDataWrapper wrapper){ - if (wrapper == null) - return null; - return wrapper.Data; - - } - public static implicit operator NodeDataWrapper(T unWrapper){ - if (unWrapper == null) - return null; - return Get(unWrapper); - } - } + // public class NodeDataWrapper : ScriptableObject where T : NodeData{ + // public T Data; + // private static readonly Dictionary> Cache = new (); + // public event Action> OnValueChanged; + // public static NodeDataWrapper Get(T data){ + // if(Cache.ContainsKey(data)){ + // return Cache[data]; + // } + // var wrapper = ScriptableObject.CreateInstance>(); + // Cache.Add(data,wrapper); + // return wrapper; + // } + // public NodeDataWrapper(T data){ + // this.Data = data; + // } + // + // public void SetValue(string path, object value){ + // var fieldInfo = Data.GetType().GetField(path); + // fieldInfo.SetValue(Data,value); + // OnValueChanged?.Invoke(this); + // } + // + // public object GetValue(string path){ + // var fieldInfo = Data.GetType().GetField(path); + // return fieldInfo.GetValue(Data); + // } + // public static implicit operator T(NodeDataWrapper wrapper){ + // if (wrapper == null) + // return null; + // return wrapper.Data; + // + // } + // public static implicit operator NodeDataWrapper(T unWrapper){ + // if (unWrapper == null) + // return null; + // return Get(unWrapper); + // } + // } public class NodeDataWrapper:DataWrapper{ } diff --git a/TNodeGraphViewImpl/Editor/GraphEditor.cs b/TNodeGraphViewImpl/Editor/GraphEditor.cs index 2a01b69..4721969 100644 --- a/TNodeGraphViewImpl/Editor/GraphEditor.cs +++ b/TNodeGraphViewImpl/Editor/GraphEditor.cs @@ -1,25 +1,60 @@ -using Codice.CM.Common; -using TNode.Editor.Inspector; +using System; +using TNodeCore.Editor; using TNodeCore.Editor.EditorPersistence; +using TNodeCore.Editor.NodeGraphView; using TNodeCore.Models; using TNodeGraphViewImpl.Editor.Cache; using TNodeGraphViewImpl.Editor.NodeGraphView; using UnityEditor; -using UnityEditor.Experimental.GraphView; using UnityEngine; using UnityEngine.Serialization; using UnityEngine.UIElements; -namespace TNode.Editor{ +namespace TNodeGraphViewImpl.Editor{ - - public abstract class GraphEditor : EditorWindow where T:GraphData{ + // public class SelectGraphWindow : EditorWindow{ + // public EditorWindow parent; + // public Type graphType; + // public static void ShowWindow (GraphEditor parent) where T:GraphData{ + // var window = GetWindow(); + // window.graphType = typeof(T); + // window.Show(); + // window.parent = parent; + // } + // private void OnGUI(){ + // + // if(GUILayout.Button("Create An Graph")){ + // //Add a save file dialog to save the graph + // //Create the graph + // var graphAsset = ScriptableObject.CreateInstance(graphType); + // var path = EditorUtility.SaveFilePanel("Save Graph", "", "", "asset"); + // //Save the graph + // AssetDatabase.CreateAsset(graphAsset, path); + // AssetDatabase.SaveAssets(); + // AssetDatabase.Refresh(); + // //Load the graph + // var graph = AssetDatabase.LoadAssetAtPath(path) as GraphData; + // var graphEditor = parent as IGraphEditor; + // if (graphEditor.GetGraphView() != null){ + // graphEditor.GetGraphView().SetGraphData(graph); + // Debug.Log(graph); + // } + // } + // //Drag and drop a graph asset to load it + // if(Event.current.type == EventType.DragUpdated){ + // DragAndDrop.visualMode = DragAndDropVisualMode.Copy; + // Event.current.Use(); + // } + // } + // } + public abstract class GraphEditor : EditorWindow,IGraphEditor where T:GraphData{ protected BaseDataGraphView GraphView; [SerializeField] private VisualTreeAsset mVisualTreeAsset = default; //Persist editor data ,such as node position,node size ,etc ,in this script object [FormerlySerializedAs("nodeEditorData")] public GraphEditorData graphEditorData; - + private bool _windowShowed=false; + public void CreateGUI(){ // Each editor window contains a root VisualElement object @@ -28,12 +63,25 @@ namespace TNode.Editor{ // Instantiate UXML VisualElement labelFromUXML = mVisualTreeAsset.Instantiate(); root.Add(labelFromUXML); - + BuildGraphView(); DefineGraphEditorActions(); OnCreate(); } - + + public void Update(){ + if (GraphView == null) return; + if (GraphView.Data != null) return; + if (_windowShowed==false){ + _windowShowed = true; + } + } + + + public void Setup(T graphData){ + GraphView.Owner = this; + GraphView.Data = graphData; + } private void BuildGraphView(){ GraphView = NodeEditorExtensions.CreateViewComponentFromBaseType>(); rootVisualElement.Add(GraphView); @@ -75,6 +123,13 @@ namespace TNode.Editor{ protected virtual void OnCreate(){ } - + + public void SetGraphView(IBaseDataGraphView graphView){ + GraphView = graphView as BaseDataGraphView; + } + + public IBaseDataGraphView GetGraphView(){ + return GraphView; + } } } diff --git a/TNodeGraphViewImpl/Editor/NodeGraphView/DataGraphView.cs b/TNodeGraphViewImpl/Editor/NodeGraphView/DataGraphView.cs index dbd8619..6c17f8f 100644 --- a/TNodeGraphViewImpl/Editor/NodeGraphView/DataGraphView.cs +++ b/TNodeGraphViewImpl/Editor/NodeGraphView/DataGraphView.cs @@ -1,11 +1,7 @@ using System; -using System.Collections; using System.Collections.Generic; using System.Linq; -using System.Reflection; -using TNode.Editor; using TNode.Editor.Inspector; -using TNode.Editor.NodeViews; using TNode.Editor.Search; using TNodeCore.Editor.Blackboard; using TNodeCore.Editor.EditorPersistence; @@ -14,7 +10,6 @@ using TNodeCore.Editor.Tools.NodeCreator; using TNodeCore.Models; using TNodeGraphViewImpl.Editor.Cache; using TNodeGraphViewImpl.Editor.GraphBlackboard; -using TNodeGraphViewImpl.Editor.GraphBlackboard.BlackboardProperty; using TNodeGraphViewImpl.Editor.NodeViews; using UnityEditor; using UnityEditor.Experimental.GraphView; @@ -116,7 +111,6 @@ namespace TNodeGraphViewImpl.Editor.NodeGraphView{ } private void OnDragUpdated(DragUpdatedEvent evt){ - Debug.Log(evt); //check if the drag data is BlackboardField @@ -376,6 +370,11 @@ namespace TNodeGraphViewImpl.Editor.NodeGraphView{ public BlackboardData GetBlackboardData(){ return this._data.blackboardData; } + + public void SetGraphData(GraphData graph){ + Data = graph as T; + } + #endregion }