Esempio n. 1
0
    private void OnGUI()
    {
        if (nodeEditor == null)
        {
            GUIGenericMenu nodeMenu = new GUIGenericMenu();

            nodeMenu.AddMenuItem("Make Transition", StartConnection);
            nodeMenu.AddMenuItem("Create Node", CreateNewNode);
            nodeMenu.AddMenuItem("Create/Items/", "Node");
            nodeMenu.AddMenuItem("Delete Node", Delete);

            nodeEditor = new NodeEditor();
            nodeEditor.EnableBoxSelect();
            nodeEditor.EnableNodeSelect();
            nodeEditor.EnableConnectorSelect();
            nodeEditor.EnableNodeDrag();
            nodeEditor.EnableNodeRightClick();
            nodeEditor.EnableConnectorRightClick();
            nodeEditor.EnableInputMode <ConnectorMakerMode>(2);

            connectorMode = new ConnectNodeInputMode(nodeEditor, 2);
            nodeEditor.EnableInputMode(connectorMode);

            Node node1 = new TextNode(Vector2.zero, "Test", null, nodeMenu);
            Node node2 = new TextNode(Vector2.one * 50f, "Test 2", null, nodeMenu);

            GUIGenericMenu connectMenu = new GUIGenericMenu();
            connectMenu.AddMenuItem("Delete Connection", DeleteConnection);
            nodeEditor.AddNode(node1);
            nodeEditor.AddNode(node2);
            //nodeEditor.AddConnector(new Connector(connectMenu, node1, node2));
            // nodeEditor.AddConnector(new Connector(connectMenu, node1, nodeEditor.MouseNode));
        }

        if (nodeEditor.OnGUI(position.WithPosition(Vector2.zero)))
        {
            Repaint();
        }
    }
Esempio n. 2
0
        public static Node MaterialNodeToUI(Material Mat, MaterialNode MatNode, NodeEditor Editor)
        {
            Node NewNode = new Node(MatNode.Name);

            NewNode.ID     = MatNode.ID;
            NewNode.Source = MatNode;
            for (int i = 0; i < MatNode.Outputs.Count; i++)
            {
                NewNode.AddNodeValue(MaterialNodeValueToUI(Mat, MatNode.Outputs[i], Editor));
            }
            for (int i = 0; i < MatNode.Inputs.Count; i++)
            {
                NewNode.AddNodeValue(MaterialNodeValueToUI(Mat, MatNode.Inputs[i], Editor));
            }
            for (int i = 0; i < MatNode.Values.Count; i++)
            {
                NewNode.AddNodeValue(MaterialNodeValueToUI(Mat, MatNode.Values[i], Editor));
            }
            Editor.AddNode(NewNode);
            return(NewNode);
        }
Esempio n. 3
0
        /// <summary>
        /// Fills the node editor with nodes that represent the scene data
        /// </summary>
        /// <param name="nodeContextMenu">The context menu to be given to each node</param>
        private void PopulateNodes(GUIGenericMenu nodeContextMenu)
        {
            SceneNodeCollection nodes = SerializedManager.SceneNodes;

            foreach (SceneNode node in nodes.SceneNodes)
            {
                node.ContextMenu = nodeContextMenu;

                node.IsEntryScene = SerializedManager.IsEntryScene(node.SceneId);

                if (node.SceneId == SceneManagerController.ANY_SCENE_ID)
                {
                    node.SceneInfo = SerializedManager.TargetManager.AnyScene;
                }
                else
                {
                    node.SceneInfo = SerializedManager.TargetManager.GetSceneById(node.SceneId);
                }

                NodeEditor.AddNode(node);
            }
        }
Esempio n. 4
0
    private void CreateNewNode(System.Object param)
    {
        Vector2 newPos = nodeEditor.GetMousePanAndZoom();

        nodeEditor.AddNode(new TextNode(newPos, "New Node"));
    }