Beispiel #1
0
        protected static void ReassignOutputType(ref NodeOutput output, Type newOutputType)
        {
            Node   body = output.body;
            string name = output.name;
            IEnumerable <NodeInput> enumerable = from connection in output.connections
                                                 where connection.typeData.Type.IsAssignableFrom(newOutputType)
                                                 select connection;

            output.Delete();
            NodeEditorCallbacks.IssueOnAddNodeKnob(NodeOutput.Create(body, name, newOutputType.AssemblyQualifiedName));
            output = body.Outputs[body.Outputs.Count - 1];
            foreach (NodeInput item in enumerable)
            {
                item.ApplyConnection(output);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Reassigns the type of the given output. This actually recreates it
        /// </summary>
        protected static void ReassignOutputType(ref NodeOutput output, Type newOutputType)
        {
            Node   body       = output.body;
            string outputName = output.name;
            // Store all valid connections that are not affected by the type change
            IEnumerable <NodeInput> validConnections = output.connections.Where((NodeInput connection) => connection.typeData.Type.IsAssignableFrom(newOutputType));

            // Delete the output of the old type
            output.Delete();
            // Create Output with new type
            NodeEditorCallbacks.IssueOnAddNodeKnob(NodeOutput.Create(body, outputName, newOutputType.AssemblyQualifiedName));
            output = body.Outputs[body.Outputs.Count - 1];
            // Restore the valid connections
            foreach (NodeInput input in validConnections)
            {
                input.ApplyConnection(output);
            }
        }
Beispiel #3
0
        protected static void ReassignInputType(ref NodeInput input, Type newInputType)
        {
            Node       body       = input.body;
            string     name       = input.name;
            NodeOutput nodeOutput = null;

            if ((UnityEngine.Object)input.connection != (UnityEngine.Object)null && newInputType.IsAssignableFrom(input.connection.typeData.Type))
            {
                nodeOutput = input.connection;
            }
            input.Delete();
            NodeEditorCallbacks.IssueOnAddNodeKnob(NodeInput.Create(body, name, newInputType.AssemblyQualifiedName));
            input = body.Inputs[body.Inputs.Count - 1];
            if ((UnityEngine.Object)nodeOutput != (UnityEngine.Object)null)
            {
                input.ApplyConnection(nodeOutput);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Reassigns the type of the given output. This actually recreates it
        /// </summary>
        protected static void ReassignInputType(ref NodeInput input, Type newInputType)
        {
            Node   body      = input.body;
            string inputName = input.name;
            // Store the valid connection if it's not affected by the type change
            NodeOutput validConnection = null;

            if (input.connection != null && newInputType.IsAssignableFrom(input.connection.typeData.Type))
            {
                validConnection = input.connection;
            }
            // Delete the input of the old type
            input.Delete();
            // Create Output with new type
            NodeEditorCallbacks.IssueOnAddNodeKnob(NodeInput.Create(body, inputName, newInputType.AssemblyQualifiedName));
            input = body.Inputs[body.Inputs.Count - 1];
            // Restore the valid connections
            if (validConnection != null)
            {
                input.ApplyConnection(validConnection);
            }
        }