Exemplo n.º 1
0
    void ToolWindowOnGUI()
    {
        GUIStyle myFoldoutStyle = new GUIStyle(EditorStyles.foldout);

        myFoldoutStyle.fontStyle = FontStyle.Bold;
        bShowAddTool             = EditorGUILayout.Foldout(bShowAddTool, "Add Node", myFoldoutStyle);
        if (bShowAddTool)
        {
            NodeBase newNode = null;
            GUILayout.Label("Add Generator");
            GUILayout.BeginHorizontal();
            {
                if (GUILayout.Button("Generator"))
                {
                    newNode = NodeBase.createNewNode(NodeType.Generator);
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.Label("Add Operator");
            GUILayout.BeginHorizontal();
            {
                if (GUILayout.Button("Unary Operator"))
                {
                    newNode = NodeBase.createNewNode(NodeType.UnaryOperator);
                }
                if (GUILayout.Button("Binary Operator"))
                {
                    newNode = NodeBase.createNewNode(NodeType.BinaryOperator);
                }
                if (GUILayout.Button("Ternary Operator"))
                {
                    newNode = NodeBase.createNewNode(NodeType.TernaryOperator);
                }
            }
            GUILayout.EndHorizontal();


            GUILayout.Label("Add Output");
            GUILayout.BeginHorizontal();
            {
                //if (GUILayout.Button("Height Output")) {
                //    newNode = NodeBase.createNewHeightOutput();
                //}
                if (GUILayout.Button("Texture Output"))
                {
                    newNode = NodeBase.createNewTextureOutput();
                }
                if (GUILayout.Button("Grass Output"))
                {
                    newNode = NodeBase.createNewGrassOutput();
                }
                if (GUILayout.Button("Tree Output"))
                {
                    newNode = NodeBase.createNewTreeOutput();
                }
            }
            GUILayout.EndHorizontal();


            if (newNode != null)
            {
                Vector2    newPos        = this.scrollPosition;
                NodeWindow newNodeWindow = NodeWindow.createNew(newNode, newPos, nodeManager.findNodeWindow, nodeManager.findNode);
                newNodeWindow.initWindow(getNewWinID(), OnNodeDelete, OnNodeSelected);
                newNode.label = getNewName(newNode.label);
                nodeManager.addNode(newNodeWindow);
            }
            GUILayout.Space(20);
        }

        if (nodeManager.findNodeWindow(curSelectedNode) != null)
        {
            bShowDetailConfig = EditorGUILayout.Foldout(bShowDetailConfig, "Detail Config", myFoldoutStyle);
            if (bShowDetailConfig)
            {
                var curNode = nodeManager.findNodeWindow(curSelectedNode);
                curNode.DrawProperty(gui);
            }
        }
    }