internal void ResolveNodesAfterSerialization(CKlaxScriptObject outerScriptObject) { ScriptableObject = outerScriptObject; for (int i = 0; i < m_nodes.Count; i++) { if (m_nodes[i] is CKlaxVariableNode variableNode) { int varIndex = variableNode.m_sourceVariableIndex; variableNode.m_sourceVariable = variableNode.m_bIsLocalVariable ? m_localVariables[varIndex] : outerScriptObject.KlaxVariables[varIndex]; } else if (m_nodes[i] is CExecuteCustomFunctionNode functionNode) { functionNode.ResolveFunctionReference(outerScriptObject); } } CScriptSerializer.ResolveNodeReferences(m_nodes); }
internal void ResolveNodesForPaste(IList <CNode> nodes) { List <CNode> invalidNodes = new List <CNode>(); for (int i = nodes.Count - 1; i >= 0; i--) { if (nodes[i] is CKlaxVariableNode variableNode) { bool bFoundVariable = false; foreach (CKlaxVariable localVariable in m_localVariables) { if (localVariable.Guid == variableNode.m_sourceVariableGuid) { variableNode.SourceVariable = localVariable; bFoundVariable = true; break; } } if (!bFoundVariable) { foreach (CKlaxVariable objectVariable in ScriptableObject.KlaxVariables) { if (objectVariable.Guid == variableNode.m_sourceVariableGuid) { bFoundVariable = true; variableNode.SourceVariable = objectVariable; break; } } } if (!bFoundVariable) { nodes.RemoveAt(i); } } else if (nodes[i] is CExecuteCustomFunctionNode functionNode) { functionNode.ResolveFunctionReference(ScriptableObject); } } CScriptSerializer.ResolveNodeReferences(nodes); }