diff --git a/README.md b/README.md index c986e22..887a729 100644 --- a/README.md +++ b/README.md @@ -14,11 +14,10 @@ the main goal of the repo is to make graph creation easier and more intuitive. * Scene object nodes hold scene objects like blackboard # Some to-dos -* Port connectivity of two types have implicit conversion -* Node placemat * Vertical node * A universal merger handle multiple input -* Support static graph data traversal +* Support graph data traversal like FSM +* Conditional edge # Install & Usage Right now this lib is still under development. diff --git a/TNode/Samples/New HelloGraph.asset b/TNode/Samples/New HelloGraph.asset index f699d86..0ea0f1e 100644 --- a/TNode/Samples/New HelloGraph.asset +++ b/TNode/Samples/New HelloGraph.asset @@ -43,8 +43,8 @@ MonoBehaviour: data: positionInView: serializedVersion: 2 - x: 297 - y: 280 + x: 519 + y: 361 width: 0 height: 0 id: 4414d05b-da96-465e-a593-2e3dcfceaf23 @@ -58,8 +58,8 @@ MonoBehaviour: data: positionInView: serializedVersion: 2 - x: 225 - y: 382 + x: 519 + y: 443 width: 0 height: 0 id: 1a4fd419-5584-4d43-a8c3-bebcad63a337 @@ -73,8 +73,8 @@ MonoBehaviour: data: positionInView: serializedVersion: 2 - x: 488 - y: 280 + x: 630 + y: 361 width: 0 height: 0 id: 3e72627f-af97-4056-b89c-04d4f2f127f5 @@ -107,6 +107,8 @@ MonoBehaviour: width: 0 height: 0 id: + CommentedModel: + id: 2 CommentText: 00000005: type: {class: GraphViewModel, ns: TNode.TNodeCore.Editor.Models, asm: NewAssembly} @@ -119,5 +121,5 @@ MonoBehaviour: height: 0 id: persistScale: 1 - persistOffset: {x: 114, y: -155} + persistOffset: {x: -302, y: -93} isBlackboardOn: 1 diff --git a/TNode/TNodeCore/Editor/CommentView/CommentView.cs b/TNode/TNodeCore/Editor/CommentView/CommentView.cs index a9a9a9a..d2bc620 100644 --- a/TNode/TNodeCore/Editor/CommentView/CommentView.cs +++ b/TNode/TNodeCore/Editor/CommentView/CommentView.cs @@ -1,6 +1,9 @@ -using TNode.TNodeCore.Editor.Binding; +using System; +using TNode.TNodeCore.Editor.Binding; using TNode.TNodeCore.Editor.Models; +using TNodeCore.Editor.NodeGraphView; using UnityEditor.Experimental.GraphView; +using UnityEngine; using UnityEngine.UIElements; namespace TNode.TNodeCore.Editor.CommentView{ @@ -14,13 +17,30 @@ namespace TNode.TNodeCore.Editor.CommentView{ public CommentView(){ var txtField = new TextField(); + var btn = new Button(() => { + var graphElement = (Node) this.GetFirstOfType(); + graphElement.Remove(this); + }); + btn.text = "-"; + this.Add(btn); this.Add(txtField); txtField.RegisterValueChangedCallback(evt => { if (_data != null){ _data.CommentText = evt.newValue; } }); + + + + capabilities |= Capabilities.Collapsible | Capabilities.Deletable|Capabilities.Selectable; + + styleSheets.Add(Resources.Load("CommentView")); + } + + private void ClickComment(){ + } + public void OnChange(){ var str = this._data.CommentText; this.Q().value = str; diff --git a/TNode/TNodeCore/Editor/Models/Comment.cs b/TNode/TNodeCore/Editor/Models/Comment.cs index c0b6854..8143709 100644 --- a/TNode/TNodeCore/Editor/Models/Comment.cs +++ b/TNode/TNodeCore/Editor/Models/Comment.cs @@ -1,7 +1,9 @@ using TNodeCore.Runtime.Models; +using UnityEngine; namespace TNode.TNodeCore.Editor.Models{ public class Comment:EditorModel{ + [SerializeReference] public Model CommentedModel; public string CommentText; } diff --git a/TNode/TNodeCore/Editor/Resources/CommentView.uss b/TNode/TNodeCore/Editor/Resources/CommentView.uss new file mode 100644 index 0000000..7501cb0 --- /dev/null +++ b/TNode/TNodeCore/Editor/Resources/CommentView.uss @@ -0,0 +1,6 @@ +TextField{ + min-width: 400px; +} +{ + flex-direction: row; +} \ No newline at end of file diff --git a/TNode/TNodeCore/Editor/Resources/CommentView.uss.meta b/TNode/TNodeCore/Editor/Resources/CommentView.uss.meta new file mode 100644 index 0000000..65b376b --- /dev/null +++ b/TNode/TNodeCore/Editor/Resources/CommentView.uss.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 03185df2d8c7459fb302d053876477b6 +timeCreated: 1660101516 \ No newline at end of file diff --git a/TNode/TNodeCore/Editor/Tools/GraphEditorCreator/GraphEditorCreator.cs b/TNode/TNodeCore/Editor/Tools/GraphEditorCreator/GraphEditorCreator.cs index aadb174..679ce25 100644 --- a/TNode/TNodeCore/Editor/Tools/GraphEditorCreator/GraphEditorCreator.cs +++ b/TNode/TNodeCore/Editor/Tools/GraphEditorCreator/GraphEditorCreator.cs @@ -146,7 +146,6 @@ namespace TNodeCore.Editor.Tools.GraphEditorCreator{ //Create an NodeAttribute Editor Data Instance for the new graph editor var graphEditorData = ScriptableObject.CreateInstance(); graphEditorData.name = editorName; - VisualTreeAsset defaultEditorTree = Resources.Load("GraphEditor"); EditorUtility.SetDirty(graphEditorData); diff --git a/TNode/TNodeCore/Runtime/Models/Model.cs b/TNode/TNodeCore/Runtime/Models/Model.cs index 429daa8..8f8a216 100644 --- a/TNode/TNodeCore/Runtime/Models/Model.cs +++ b/TNode/TNodeCore/Runtime/Models/Model.cs @@ -11,6 +11,7 @@ namespace TNodeCore.Runtime.Models{ public Rect positionInView; #endif [DisableOnInspector] + [HideInBlackboard] public string id; [NonSerialized] private int _fastAccessId=0; diff --git a/TNode/TNodeGraphViewImpl/Editor/GraphBlackboard/DefaultGraphBlackboardView.cs b/TNode/TNodeGraphViewImpl/Editor/GraphBlackboard/DefaultGraphBlackboardView.cs index ed707bb..d460b0c 100644 --- a/TNode/TNodeGraphViewImpl/Editor/GraphBlackboard/DefaultGraphBlackboardView.cs +++ b/TNode/TNodeGraphViewImpl/Editor/GraphBlackboard/DefaultGraphBlackboardView.cs @@ -35,6 +35,7 @@ namespace TNode.TNodeGraphViewImpl.Editor.GraphBlackboard{ foreach (var field in data.GetType() .GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)){ if(field.GetCustomAttributes(typeof(HideInBlackboard)).Count()!=0) continue; + //if the field is MonoBehaviour,add a property field for blackboard //skip if the field is a list or Ilist if (!typeof(IList).IsAssignableFrom(field.FieldType)&&!field.FieldType.IsArray){