feature:add a delete button for comment

main
taoria 3 years ago
parent b8494278cf
commit 1ae31eb057
  1. 5
      README.md
  2. 16
      TNode/Samples/New HelloGraph.asset
  3. 22
      TNode/TNodeCore/Editor/CommentView/CommentView.cs
  4. 2
      TNode/TNodeCore/Editor/Models/Comment.cs
  5. 6
      TNode/TNodeCore/Editor/Resources/CommentView.uss
  6. 3
      TNode/TNodeCore/Editor/Resources/CommentView.uss.meta
  7. 1
      TNode/TNodeCore/Editor/Tools/GraphEditorCreator/GraphEditorCreator.cs
  8. 1
      TNode/TNodeCore/Runtime/Models/Model.cs
  9. 1
      TNode/TNodeGraphViewImpl/Editor/GraphBlackboard/DefaultGraphBlackboardView.cs

@ -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.

@ -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

@ -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<Node>();
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<StyleSheet>("CommentView"));
}
private void ClickComment(){
}
public void OnChange(){
var str = this._data.CommentText;
this.Q<TextField>().value = str;

@ -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;
}

@ -0,0 +1,6 @@
TextField{
min-width: 400px;
}
{
flex-direction: row;
}

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 03185df2d8c7459fb302d053876477b6
timeCreated: 1660101516

@ -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>();
graphEditorData.name = editorName;
VisualTreeAsset defaultEditorTree = Resources.Load<VisualTreeAsset>("GraphEditor");
EditorUtility.SetDirty(graphEditorData);

@ -11,6 +11,7 @@ namespace TNodeCore.Runtime.Models{
public Rect positionInView;
#endif
[DisableOnInspector]
[HideInBlackboard]
public string id;
[NonSerialized]
private int _fastAccessId=0;

@ -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){

Loading…
Cancel
Save