feature:start building comment block

main
taoria 3 years ago
parent 50c30a69e3
commit 07384a387b
  1. 147
      TNode/Samples/New HelloGraph.asset
  2. 2
      TNode/Samples/New HelloGraph.asset.meta
  3. 3
      TNode/TNodeCore/Editor/Binding.meta
  4. 7
      TNode/TNodeCore/Editor/Binding/IModelBinding.cs
  5. 3
      TNode/TNodeCore/Editor/Binding/IModelBinding.cs.meta
  6. 3
      TNode/TNodeCore/Editor/CommentView.meta
  7. 29
      TNode/TNodeCore/Editor/CommentView/CommentView.cs
  8. 3
      TNode/TNodeCore/Editor/CommentView/CommentView.cs.meta
  9. 8
      TNode/TNodeCore/Editor/Models/Comment.cs
  10. 3
      TNode/TNodeCore/Editor/Models/Comment.cs.meta
  11. 9
      TNode/TNodeCore/Runtime/Models/Model.cs
  12. 3
      TNode/TNodeCore/Runtime/Models/NodeData.cs
  13. 4
      TNode/TNodeGraphViewImpl/Editor/GraphBlackboard/DefaultGraphBlackboardView.cs
  14. 22
      TNode/TNodeGraphViewImpl/Editor/NodeGraphView/DataGraphView.cs

@ -16,128 +16,71 @@ MonoBehaviour:
- id: 0 - id: 0
- id: 1 - id: 1
- id: 2 - id: 2
- id: 3 nodeLinks:
- id: 4 - inPort:
- id: 5 portEntryName: A
- id: 6 nodeDataId: 3e72627f-af97-4056-b89c-04d4f2f127f5
- id: 7 outPort:
nodeLinks: [] portEntryName: Value
nodeDataId: 4414d05b-da96-465e-a593-2e3dcfceaf23
- inPort:
portEntryName: B
nodeDataId: 3e72627f-af97-4056-b89c-04d4f2f127f5
outPort:
portEntryName: Value
nodeDataId: 1a4fd419-5584-4d43-a8c3-bebcad63a337
blackboardData: blackboardData:
id: 8 id: 3
sceneReference: sceneReference:
editorModels: editorModels: []
- id: 9 graphViewModel:
graphViewData: id: 4
id: 10
references: references:
version: 1 version: 1
00000000: 00000000:
type: {class: AddNode, ns: Samples, asm: Assembly-CSharp} type: {class: BlackboardDragNodeData, ns: TNodeCore.Runtime.Models, asm: NewAssembly}
data: data:
positionInView: positionInView:
serializedVersion: 2 serializedVersion: 2
x: 1944 x: 297
y: 205 y: 280
width: 0 width: 0
height: 0 height: 0
id: 74136d91-e634-401b-8c99-3c2bb351cab2 id: 4414d05b-da96-465e-a593-2e3dcfceaf23
nodeName: AddNode nodeName:
entryPoint: 0 entryPoint: 0
isTest: 0 isTest: 0
blackDragData: V3S.0
isListElement: 1
00000001: 00000001:
type: {class: AddNode, ns: Samples, asm: Assembly-CSharp} type: {class: AddNode, ns: Samples, asm: Assembly-CSharp}
data: data:
positionInView: positionInView:
serializedVersion: 2 serializedVersion: 2
x: 2045 x: 454
y: 205 y: 280
width: 0 width: 0
height: 0 height: 0
id: 8bee0814-52ef-4068-bffb-58a786d73ec2 id: 3e72627f-af97-4056-b89c-04d4f2f127f5
nodeName: AddNode nodeName: AddNode
entryPoint: 0 entryPoint: 0
isTest: 0 isTest: 0
00000002: 00000002:
type: {class: AddNode, ns: Samples, asm: Assembly-CSharp}
data:
positionInView:
serializedVersion: 2
x: 2146
y: 205
width: 0
height: 0
id: 819d1689-d64d-41ca-a9ac-0e00d25806c0
nodeName: AddNode
entryPoint: 0
isTest: 0
00000003:
type: {class: AddNode, ns: Samples, asm: Assembly-CSharp}
data:
positionInView:
serializedVersion: 2
x: 2247
y: 205
width: 0
height: 0
id: b8495e41-8ec2-4015-8784-7a99c1003c6b
nodeName: AddNode
entryPoint: 0
isTest: 0
00000004:
type: {class: AddNode, ns: Samples, asm: Assembly-CSharp}
data:
positionInView:
serializedVersion: 2
x: 2014
y: 340
width: 0
height: 0
id: 3f27f6fe-b2db-41f2-9b3f-5e5fc468e536
nodeName: AddNode
entryPoint: 0
isTest: 0
00000005:
type: {class: AddNode, ns: Samples, asm: Assembly-CSharp}
data:
positionInView:
serializedVersion: 2
x: 2130
y: 340
width: 0
height: 0
id: 6500c6c2-3551-4930-8338-afd02a49105b
nodeName: AddNode
entryPoint: 0
isTest: 0
00000006:
type: {class: AddNode, ns: Samples, asm: Assembly-CSharp}
data:
positionInView:
serializedVersion: 2
x: 2247
y: 340
width: 0
height: 0
id: 002de40a-5ef5-4e99-8373-2628d189d6c9
nodeName: AddNode
entryPoint: 0
isTest: 0
00000007:
type: {class: BlackboardDragNodeData, ns: TNodeCore.Runtime.Models, asm: NewAssembly} type: {class: BlackboardDragNodeData, ns: TNodeCore.Runtime.Models, asm: NewAssembly}
data: data:
positionInView: positionInView:
serializedVersion: 2 serializedVersion: 2
x: 1944.9998 x: 225
y: 475.8858 y: 382
width: 0 width: 0
height: 0 height: 0
id: 2f9adf6b-b40b-4fbd-9bd6-0d1ebb10992f id: 1a4fd419-5584-4d43-a8c3-bebcad63a337
nodeName: nodeName:
entryPoint: 0 entryPoint: 0
isTest: 0 isTest: 0
blackDragData: HelloGameObject blackDragData: V2S.0
isListElement: 0 isListElement: 1
00000008: 00000003:
type: {class: HelloBlackboard, ns: TNode.Samples, asm: Assembly-CSharp} type: {class: HelloBlackboard, ns: TNode.Samples, asm: Assembly-CSharp}
data: data:
positionInView: positionInView:
@ -146,26 +89,14 @@ MonoBehaviour:
y: 0 y: 0
width: 0 width: 0
height: 0 height: 0
HelloString: hello HelloString:
HelloGameObject: {fileID: 3675195758153116951, guid: 35a9f7ccd0ed7d744b85580016a0aab5, type: 3} HelloGameObject: {fileID: 0}
V3S: V3S:
- {x: 0, y: 0, z: 0} - {x: 0, y: 0, z: 0}
V2S: V2S:
- {x: 0, y: 0} - {x: 0, y: 0}
00000009: 00000004:
type: {class: PlacematData, ns: TNodeCore.Editor.Models, asm: NewAssembly} type: {class: GraphViewModel, ns: TNode.TNodeCore.Editor.Models, asm: NewAssembly}
data:
positionInView:
serializedVersion: 2
x: 1903.9056
y: 75.76817
width: 500
height: 500
hostModels: []
zOrder: 0
title: Title
0000000A:
type: {class: GraphViewData, ns: TNode.TNodeCore.Editor.Models, asm: NewAssembly}
data: data:
positionInView: positionInView:
serializedVersion: 2 serializedVersion: 2
@ -173,6 +104,6 @@ MonoBehaviour:
y: 0 y: 0
width: 0 width: 0
height: 0 height: 0
persistScale: 0.8695652 persistScale: 0.57175326
persistOffset: {x: -878, y: -29} persistOffset: {x: 343, y: 15}
isBlackboardOn: 1 isBlackboardOn: 1

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 490933fc590be444780d73cd9f777ed4 guid: f55ebad0b05015a4f873ac78896d95d3
NativeFormatImporter: NativeFormatImporter:
externalObjects: {} externalObjects: {}
mainObjectFileID: 11400000 mainObjectFileID: 11400000

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 919363d9cb9c43a1a14fb12abc76a53b
timeCreated: 1660042822

@ -0,0 +1,7 @@
namespace TNode.TNodeCore.Editor.Binding{
public interface IModelBinding<T>{
public T Data{ get; }
public void Bind(T data);
public void OnChange();
}
}

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: c25080540d844798a8c71e2b8feadf93
timeCreated: 1660042832

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a5166d364fc64b82bce9580b4411c83e
timeCreated: 1660042541

@ -0,0 +1,29 @@
using TNode.TNodeCore.Editor.Binding;
using TNode.TNodeCore.Editor.Models;
using UnityEditor.Experimental.GraphView;
using UnityEngine.UIElements;
namespace TNode.TNodeCore.Editor.CommentView{
public class CommentView:GraphElement,IModelBinding<Comment>{
public Comment Data => _data;
private Comment _data;
public void Bind(Comment data){
_data = data;
OnChange();
}
public CommentView(){
var txtField = new TextField();
this.Add(txtField);
txtField.RegisterValueChangedCallback(evt => {
if (_data != null){
_data.CommentText = evt.newValue;
}
});
}
public void OnChange(){
var str = this._data.CommentText;
this.Q<TextField>().value = str;
}
}
}

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: e0f3542295fd4138967335f3ce44b5f2
timeCreated: 1660042529

@ -0,0 +1,8 @@
using TNodeCore.Runtime.Models;
namespace TNode.TNodeCore.Editor.Models{
public class Comment:EditorModel{
public Model CommentedModel;
public string CommentText;
}
}

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a7a79224e74245789ccaa833d12b833d
timeCreated: 1660041914

@ -10,10 +10,17 @@ namespace TNodeCore.Runtime.Models{
[HideInBlackboard] [HideInBlackboard]
public Rect positionInView; public Rect positionInView;
#endif #endif
[DisableOnInspector]
public string id;
[NonSerialized]
private int _fastAccessId=0;
public object Clone(){ public object Clone(){
var memberwiseClone = this.MemberwiseClone(); var memberwiseClone = this.MemberwiseClone();
return memberwiseClone; return memberwiseClone;
} }
/// <summary>
/// Record and map the node by a string is cost.converted it to an integer to speed the process.
/// </summary>
public int FastAccessId => _fastAccessId==0?_fastAccessId=GetHashCode():_fastAccessId;
} }
} }

@ -18,8 +18,7 @@ namespace TNodeCore.Runtime.Models{
//Object Registration //Object Registration
} }
[DisableOnInspector]
public string id;
public string nodeName; public string nodeName;
public bool entryPoint; public bool entryPoint;

@ -86,7 +86,7 @@ namespace TNode.TNodeGraphViewImpl.Editor.GraphBlackboard{
private static void CreateBlackboardDataEntryForListItem(FieldInfo field, SerializedObject serializedObject, private static void CreateBlackboardDataEntryForListItem(FieldInfo field, SerializedObject serializedObject,
bool isRuntimeGraph, bool isRuntimeGraph,
BlackboardSection blackboardSection, int index){ BlackboardSection blackboardSection, int index){
var property = serializedObject.FindProperty("model"); var property = serializedObject.FindProperty("data");
property = property.FindPropertyRelative(field.Name).GetArrayElementAtIndex(index); property = property.FindPropertyRelative(field.Name).GetArrayElementAtIndex(index);
BlackboardDataEntry entry = new BlackboardDataEntry(field.FieldType){ BlackboardDataEntry entry = new BlackboardDataEntry(field.FieldType){
@ -112,7 +112,7 @@ namespace TNode.TNodeGraphViewImpl.Editor.GraphBlackboard{
var foldoutData = new Foldout{ var foldoutData = new Foldout{
}; };
var drawer = var drawer =
new GraphBlackboardPropertyField(serializedObject.FindProperty("model").FindPropertyRelative(field.Name), new GraphBlackboardPropertyField(serializedObject.FindProperty("data").FindPropertyRelative(field.Name),
isRuntimeGraph); isRuntimeGraph);
drawer.Bind(serializedObject); drawer.Bind(serializedObject);
foldoutData.Add(drawer); foldoutData.Add(drawer);

@ -211,9 +211,26 @@ namespace TNode.TNodeGraphViewImpl.Editor.NodeGraphView{
AddPlacemat(placematData); AddPlacemat(placematData);
}); });
if (this.selection.Any()){
evt.menu.AppendAction("Comment", dma => {
BuildCommentForSelected();
});
evt.menu.AppendAction("Delete", dma => {
DeleteSelected();
});
}
}); });
} }
private void BuildCommentForSelected(){
throw new NotImplementedException();
}
private void DeleteSelected(){
throw new NotImplementedException();
}
private void AddPlacemat(PlacematModel model){ private void AddPlacemat(PlacematModel model){
_data.EditorModels.Add(model); _data.EditorModels.Add(model);
} }
@ -294,7 +311,9 @@ namespace TNode.TNodeGraphViewImpl.Editor.NodeGraphView{
text = "Run Once" text = "Run Once"
}; };
runButton.RegisterCallback<ClickEvent>(evt => { runButton.RegisterCallback<ClickEvent>(evt => {
Debug.Log(IsRuntimeGraph);
if (IsRuntimeGraph){ if (IsRuntimeGraph){
_runtimeGraph.TraverseAll(); _runtimeGraph.TraverseAll();
AfterGraphResolved?.Invoke(); AfterGraphResolved?.Invoke();
} }
@ -379,10 +398,7 @@ namespace TNode.TNodeGraphViewImpl.Editor.NodeGraphView{
ClearAll(); ClearAll();
LoadPersistentGraphViewData(); LoadPersistentGraphViewData();
if (_nodeDict == null) throw new ArgumentNullException(nameof(_nodeDict)); if (_nodeDict == null) throw new ArgumentNullException(nameof(_nodeDict));
foreach (var dataNode in _data.NodeDictionary.Values){ foreach (var dataNode in _data.NodeDictionary.Values){
if(dataNode==null) if(dataNode==null)
continue; continue;

Loading…
Cancel
Save