fix: fix bug of reset

main
taoria 3 years ago
parent 4a1ada67db
commit 61abd31d12
  1. 54
      Samples/New HelloGraph.asset
  2. 2
      Samples/Nodes/AddNode.cs
  3. 2
      TNodeCore/Runtime/Logger/NodeLogger.cs
  4. 9
      TNodeCore/Runtime/RuntimeCache/RuntimeCache.cs
  5. 2
      TNodeCore/Runtime/RuntimeModels/RuntimeNode.cs
  6. 2
      TNodeCore/Runtime/Tools/GraphTool.cs
  7. 3
      TNodeGraphViewImpl/Editor/GraphWatcherView/GraphWatcherView.cs

@ -18,6 +18,7 @@ MonoBehaviour:
- id: 2 - id: 2
- id: 3 - id: 3
- id: 4 - id: 4
- id: 5
nodeLinks: nodeLinks:
- inPort: - inPort:
portEntryName: A portEntryName: A
@ -38,17 +39,17 @@ MonoBehaviour:
portEntryName: C portEntryName: C
nodeDataId: 4300534d-023d-4b56-a0cb-39e197e68845 nodeDataId: 4300534d-023d-4b56-a0cb-39e197e68845
- inPort: - inPort:
portEntryName: A portEntryName: B
nodeDataId: 926f2eea-3403-4663-88bd-7ed16ce029fa nodeDataId: 926f2eea-3403-4663-88bd-7ed16ce029fa
outPort: outPort:
portEntryName: Bigger portEntryName: Value
nodeDataId: f236a611-cc64-4fce-88d2-40baf7f4a490 nodeDataId: 7faced8f-0880-4fc3-b26b-aac148024af8
blackboardData: blackboardData:
id: 5 id: 6
sceneReference: sceneReference:
editorModels: [] editorModels: []
graphViewModel: graphViewModel:
id: 6 id: 7
references: references:
version: 1 version: 1
00000000: 00000000:
@ -57,7 +58,7 @@ MonoBehaviour:
positionInView: positionInView:
serializedVersion: 2 serializedVersion: 2
x: 674 x: 674
y: 261 y: 239
width: 0 width: 0
height: 0 height: 0
id: 6dba1aab-0db9-45a0-b3f7-e8fe9c47c168 id: 6dba1aab-0db9-45a0-b3f7-e8fe9c47c168
@ -73,8 +74,8 @@ MonoBehaviour:
data: data:
positionInView: positionInView:
serializedVersion: 2 serializedVersion: 2
x: 674 x: 676
y: 330 y: 281
width: 0 width: 0
height: 0 height: 0
id: 5fd53e10-e727-45e3-8458-04a6ec8581c4 id: 5fd53e10-e727-45e3-8458-04a6ec8581c4
@ -90,8 +91,8 @@ MonoBehaviour:
data: data:
positionInView: positionInView:
serializedVersion: 2 serializedVersion: 2
x: 784 x: 786
y: 252 y: 228
width: 0 width: 0
height: 0 height: 0
id: 4300534d-023d-4b56-a0cb-39e197e68845 id: 4300534d-023d-4b56-a0cb-39e197e68845
@ -103,8 +104,8 @@ MonoBehaviour:
data: data:
positionInView: positionInView:
serializedVersion: 2 serializedVersion: 2
x: 917 x: 928
y: 228 y: 189
width: 0 width: 0
height: 0 height: 0
id: f236a611-cc64-4fce-88d2-40baf7f4a490 id: f236a611-cc64-4fce-88d2-40baf7f4a490
@ -116,8 +117,8 @@ MonoBehaviour:
data: data:
positionInView: positionInView:
serializedVersion: 2 serializedVersion: 2
x: 1145.4003 x: 1168
y: 188.50003 y: 188
width: 0 width: 0
height: 0 height: 0
id: 926f2eea-3403-4663-88bd-7ed16ce029fa id: 926f2eea-3403-4663-88bd-7ed16ce029fa
@ -125,6 +126,23 @@ MonoBehaviour:
entryPoint: 0 entryPoint: 0
isTest: 0 isTest: 0
00000005: 00000005:
type: {class: BlackboardDragNode, ns: TNodeCore.Runtime.Models, asm: Taoria.TNodeCore.Runtime}
data:
positionInView:
serializedVersion: 2
x: 1056.5
y: 315
width: 0
height: 0
id: 7faced8f-0880-4fc3-b26b-aac148024af8
nodeName:
entryPoint: 0
isTest: 0
blackboardDragTypeString: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089
blackDragData: Value.0
isListElement: 1
00000006:
type: {class: HelloBlackboard, ns: TNode.Samples, asm: Assembly-CSharp} type: {class: HelloBlackboard, ns: TNode.Samples, asm: Assembly-CSharp}
data: data:
positionInView: positionInView:
@ -137,9 +155,9 @@ MonoBehaviour:
HelloString: HelloString:
HelloGameObject: {fileID: 0} HelloGameObject: {fileID: 0}
Value: Value:
- 24.41 - 23.9
- 102.1 - 102.1
00000006: 00000007:
type: {class: GraphViewModel, ns: TNode.TNodeCore.Editor.Models, asm: Taoria.TNodeCore.Runtime} type: {class: GraphViewModel, ns: TNode.TNodeCore.Editor.Models, asm: Taoria.TNodeCore.Runtime}
data: data:
positionInView: positionInView:
@ -149,6 +167,6 @@ MonoBehaviour:
width: 0 width: 0
height: 0 height: 0
id: id:
persistScale: 0.8695652 persistScale: 0.57175326
persistOffset: {x: -125, y: 184} persistOffset: {x: -366, y: 193}
isBlackboardOn: 1 isBlackboardOn: 1

@ -12,7 +12,7 @@ namespace Samples.Nodes{
[Output] public float C => A + B; [Output] public float C => A + B;
public override void Process(){ public override void Process(){
this.Log($"{C}");
} }
} }
} }

@ -10,7 +10,7 @@ namespace TNodeCore.Runtime{
if (!Loggers.ContainsKey(t.id)) return; if (!Loggers.ContainsKey(t.id)) return;
var nodeLoggerImpl = Loggers[t.id]; var nodeLoggerImpl = Loggers[t.id];
nodeLoggerImpl.Log(message); nodeLoggerImpl.Log(message);
Debug.Log(message);
} }
} }

@ -29,8 +29,11 @@ namespace TNodeCore.Runtime.RuntimeCache{
Set = (Action<T1, T2>)Delegate.CreateDelegate(typeof(Action<T1, T2>), null, setter); Set = (Action<T1, T2>)Delegate.CreateDelegate(typeof(Action<T1, T2>), null, setter);
if (Set != null){ if (Set != null){
var dummy = Activator.CreateInstance<T1>(); var dummy = Activator.CreateInstance<T1>();
if (Get != null) _defaultValue = Get(dummy);
_resetFunc = (obj) => { if (Get != null)
_defaultValue = Get(dummy);
_resetFunc += (obj) => {
Set(obj, _defaultValue); Set(obj, _defaultValue);
}; };
} }
@ -59,7 +62,7 @@ namespace TNodeCore.Runtime.RuntimeCache{
public void Reset(object model){ public void Reset(object model){
//Get //Get
_resetFunc((T1)model); _resetFunc?.Invoke((T1)model);
} }
public Type Type{ get; set; } public Type Type{ get; set; }

@ -124,7 +124,7 @@ namespace TNodeCore.Runtime{
public void ResetPortValue(){ public void ResetPortValue(){
foreach (var modelPortAccessor in _portAccessors){ foreach (var modelPortAccessor in _portAccessors){
modelPortAccessor.Value.Reset(this); modelPortAccessor.Value.Reset(this.NodeData);
} }
} }
public List<string> GetInputNodesId(){ public List<string> GetInputNodesId(){

@ -298,7 +298,7 @@ namespace TNode.TNodeCore.Runtime.Tools{
var cachedKey = $"{outNode.NodeData.id}-{nodeLink.inPort.portEntryName}"; var cachedKey = $"{outNode.NodeData.id}-{nodeLink.inPort.portEntryName}";
var outValue = OutputCached.ContainsKey(cachedKey) ? OutputCached[cachedKey] : outNode.GetOutput(nodeLink.outPort.portEntryName); var outValue = OutputCached.ContainsKey(cachedKey) ? OutputCached[cachedKey] : outNode.GetOutput(nodeLink.outPort.portEntryName);
Debug.Log(outValue);
if (_isCachingOutput){ if (_isCachingOutput){
OutputCached[cachedKey] = outValue; OutputCached[cachedKey] = outValue;
} }

@ -49,6 +49,9 @@ namespace TNodeGraphViewImpl.Editor.GraphWatcherView{
_highlightedNode.style.borderRightWidth = _highlightedNode.style.borderTopWidth = 0; _highlightedNode.style.borderRightWidth = _highlightedNode.style.borderTopWidth = 0;
} }
runtimeNodeGraph.ResetState(); runtimeNodeGraph.ResetState();
foreach (var runtimeNode in runtimeNodeGraph.GetRuntimeNodes()){
runtimeNode.ResetPortValue();
}
} }
}; };

Loading…
Cancel
Save