Example #1
0
            internal NodeCanvas AddNode(NodeCanvas nodecanvas)
            {
                if (this.runners.Count == 0)
                {
                    //init node runtime
                    ConnectionPortStyles.FetchConnectionPortStyles();
                    NodeTypes.FetchNodeTypes();
                    NodeCanvasManager.FetchCanvasTypes();
                    ConnectionPortManager.FetchNodeConnectionDeclarations();
                    ImportExportManager.FetchIOFormats();

                    // Setup Callback system
                    NodeEditorCallbacks.SetupReceivers();
                    NodeEditorCallbacks.IssueOnEditorStartUp();
                }

                if (nodecanvas == null)
                {
                    return(null);
                }

                NodeCanvas copycanvas = NodeEditorSaveManager.CreateWorkingCopy(nodecanvas, true);

                //push copy to runners
                runners.Add(copycanvas);

                Restart(copycanvas);
                return(copycanvas);
            }
Example #2
0
    public void LoadTextures()
    {
        //var foo = ConnectionPortStyles.GetPortStyle("tex");
        ValueConnectionKnobAttribute outKnobAttribs = new ValueConnectionKnobAttribute("Output", Direction.Out, typeof(Texture), NodeSide.Bottom);
        var texStyle = ConnectionPortStyles.GetPortStyle(outKnobAttribs.StyleID);

        this.TimedDebug("texStyleID: " + outKnobAttribs.StyleID, 2);
        texStyle.SetColor(Color.yellow);
        textures = new List <Texture2D>(Resources.LoadAll <Texture2D>("StaticTextures"));
        if (texKnobs == null)
        {
            texKnobs = new SerialDict <string, ValueConnectionKnob>();
        }
        if (texNames == null)
        {
            texNames = new List <string>();
        }
        List <string>    loadedValues  = new List <string>(textures.Select(t => t.name));
        HashSet <string> removedValues = new HashSet <string>(texNames);

        removedValues.ExceptWith(loadedValues);
        HashSet <string> addedValues = new HashSet <string>(loadedValues);

        addedValues.ExceptWith(texNames);
        //Rewire connection ports from loaded strings
        foreach (string texName in texNames)
        {
            texKnobs[texName] = (ValueConnectionKnob)dynamicConnectionPorts[texNames.IndexOf(texName)];
        }
        //Remove any ports for textures that were removed
        foreach (string texName in removedValues)
        {
            dynamicConnectionPorts.Remove(texKnobs[texName]);
        }
        // Add ports for any textures that were added
        foreach (string texName in addedValues)
        {
            texKnobs[texName] = CreateValueConnectionKnob(outKnobAttribs);
            texNames.Add(texName);
        }
    }