From 7f5001cb60ec6d19596108f146706f758fb04079 Mon Sep 17 00:00:00 2001 From: taoria <445625470@qq.com> Date: Thu, 28 Jul 2022 16:17:46 +0800 Subject: [PATCH] fix:delay a feature cause losing output data during runtime --- .../Runtime/Attributes/PortTypeConversion.cs | 2 +- .../Runtime/Components/RuntimeGraph.cs | 31 ++++++++++++++++--- TNode/TNodeCore/Runtime/RuntimeNode.cs | 2 -- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/TNode/TNodeCore/Runtime/Attributes/PortTypeConversion.cs b/TNode/TNodeCore/Runtime/Attributes/PortTypeConversion.cs index a2e8591..13161cd 100644 --- a/TNode/TNodeCore/Runtime/Attributes/PortTypeConversion.cs +++ b/TNode/TNodeCore/Runtime/Attributes/PortTypeConversion.cs @@ -1,3 +1,3 @@ -namespace TNodeCore.Attribute{ +namespace TNode.TNodeCore.Runtime.Attributes{ } \ No newline at end of file diff --git a/TNode/TNodeCore/Runtime/Components/RuntimeGraph.cs b/TNode/TNodeCore/Runtime/Components/RuntimeGraph.cs index f890154..cdbf8ad 100644 --- a/TNode/TNodeCore/Runtime/Components/RuntimeGraph.cs +++ b/TNode/TNodeCore/Runtime/Components/RuntimeGraph.cs @@ -185,6 +185,7 @@ namespace TNodeCore.Components{ /// Build the graph tool and other dependencies for the runtime graph /// public void Build(){ + if (_build) return; var link = graphData.NodeLinks; //iterate links and create runtime nodes @@ -259,15 +260,35 @@ namespace TNodeCore.Components{ public List GetRuntimeNodesOfType(Type type){ return RuntimeNodes.Values.Where(x => type.IsAssignableFrom(type)).ToList(); } - public void RunNodesOfType(Type t){ + public void RunNodesOfType(Type t,bool isCaching= false){ var nodes = GetRuntimeNodesOfType(t); - _graphTool.StartCachingPort(); + if(isCaching) + _graphTool.StartCachingPort(); foreach (var runtimeNode in nodes){ RunOnDependency(runtimeNode.NodeData); } - _graphTool.EndCachingPort(); - - + if(isCaching) + _graphTool.EndCachingPort(); + } + + /// + /// Run some nodes ,if the node is not in the graph ,then pass + /// + /// + /// + public void RunNodes(List runtimeNodes,bool isCaching= false){ + if (isCaching){ + _graphTool.StartCachingPort(); + } + foreach (var runtimeNode in runtimeNodes){ + if(!RuntimeNodes.ContainsKey(runtimeNode.NodeData.id)){ + continue; + } + RunOnDependency(runtimeNode.NodeData); + } + if (isCaching){ + _graphTool.EndCachingPort(); + } } private void ModifyOrCreateOutNode(NodeLink linkData){ var outNodeId = linkData.outPort.nodeDataId; diff --git a/TNode/TNodeCore/Runtime/RuntimeNode.cs b/TNode/TNodeCore/Runtime/RuntimeNode.cs index d73fef0..5a6bd1b 100644 --- a/TNode/TNodeCore/Runtime/RuntimeNode.cs +++ b/TNode/TNodeCore/Runtime/RuntimeNode.cs @@ -21,8 +21,6 @@ namespace TNodeCore.Runtime{ public void SetInput(string portName,object value){ var valueType = value.GetType(); var portType = _portAccessors[portName].Type; - Debug.Log(valueType); - Debug.Log(portType); if(portType!=valueType && !portType.IsAssignableFrom(valueType)){ var res =RuntimeCache.RuntimeCache.Instance.GetConvertedValue(valueType, portType, value); _portAccessors[portName].SetValue(this.NodeData, res);