示例#1
0
        public static NodeEditorWindow OpenNodeEditor()
        {
            _editor         = GetWindow <NodeEditorWindow>();
            _editor.minSize = new Vector2(400, 200);

            NodeEditor.ReInit(false);
            Texture iconTexture = NodeResourceManager.LoadTexture(EditorGUIUtility.isProSkin? "Textures/Icon_Dark.png" : "Textures/Icon_Light.png");

            _editor.titleContent = new GUIContent("Node Editor", iconTexture);

            return(_editor);
        }
示例#2
0
        public static bool Init()
        {
            // Textures
            Background       = NodeResourceManager.LoadTexture("Textures/background.png");
            AALineTex        = NodeResourceManager.LoadTexture("Textures/AALine.png");
            GUIBox           = NodeResourceManager.LoadTexture("Textures/NE_Box.png");
            GUIButton        = NodeResourceManager.LoadTexture("Textures/NE_Button.png");
            GUIBoxSelection  = NodeResourceManager.LoadTexture("Textures/BoxSelection.png");
            GUIToolbar       = NodeResourceManager.LoadTexture("Textures/NE_Toolbar.png");
            GUIToolbarButton = NodeResourceManager.LoadTexture("Textures/NE_ToolbarButton.png");

            if (!Background || !AALineTex || !GUIBox || !GUIButton || !GUIToolbar || !GUIToolbarButton)
            {
                return(false);
            }

            // Skin & Styles
            nodeSkin = Object.Instantiate(GUI.skin);
            GUI.skin = nodeSkin;

            foreach (GUIStyle style in GUI.skin)
            {
                style.fontSize = 11;
                //style.normal.textColor = style.active.textColor = style.focused.textColor = style.hover.textColor = NE_TextColor;
            }

            // Label
            nodeSkin.label.normal.textColor = NE_TextColor;
            nodeLabel     = nodeSkin.label;
            nodeLabelBold = new GUIStyle(nodeLabel)
            {
                fontStyle = FontStyle.Bold
            };
            nodeLabelSelected = new GUIStyle(nodeLabel);
            nodeLabelSelected.normal.background = RTEditorGUI.ColorToTex(1, NE_LightColor);
            nodeLabelCentered = new GUIStyle(nodeLabel)
            {
                alignment = TextAnchor.MiddleCenter
            };
            nodeLabelBoldCentered = new GUIStyle(nodeLabelBold)
            {
                alignment = TextAnchor.MiddleCenter
            };
            nodeLabelLeft = new GUIStyle(nodeLabel)
            {
                alignment = TextAnchor.MiddleLeft
            };
            nodeLabelRight = new GUIStyle(nodeLabel)
            {
                alignment = TextAnchor.MiddleRight
            };

            // Box
            nodeSkin.box.normal.background = GUIBox;
            nodeSkin.box.normal.textColor  = NE_TextColor;
            nodeSkin.box.active.textColor  = NE_TextColor;
            nodeBox     = nodeSkin.box;
            nodeBoxBold = new GUIStyle(nodeBox)
            {
                fontStyle = FontStyle.Bold
            };

            // Button
            nodeSkin.button.normal.textColor  = NE_TextColor;
            nodeSkin.button.normal.background = GUIButton;

            // Toolbar
            toolbar         = GUI.skin.FindStyle("toolbar");
            toolbarButton   = GUI.skin.FindStyle("toolbarButton");
            toolbarLabel    = GUI.skin.FindStyle("toolbarButton");
            toolbarDropdown = GUI.skin.FindStyle("toolbarDropdown");
            if (toolbar == null || toolbarButton == null || toolbarLabel == null || toolbarDropdown == null)
            {             // No editor styles available - use custom skin
                toolbar = new GUIStyle(nodeSkin.box);
                toolbar.normal.background = GUIToolbar;
                toolbar.active.background = GUIToolbar;
                toolbar.border            = new RectOffset(0, 0, 1, 1);
                toolbar.margin            = new RectOffset(0, 0, 0, 0);
                toolbar.padding           = new RectOffset(10, 10, 1, 1);

                toolbarLabel = new GUIStyle(nodeSkin.box);
                toolbarLabel.normal.background = GUIToolbarButton;
                toolbarLabel.border            = new RectOffset(2, 2, 0, 0);
                toolbarLabel.margin            = new RectOffset(-2, -2, 0, 0);
                toolbarLabel.padding           = new RectOffset(6, 6, 4, 4);

                toolbarButton = new GUIStyle(toolbarLabel);
                toolbarButton.active.background = RTEditorGUI.ColorToTex(1, NE_LightColor);

                toolbarDropdown = new GUIStyle(toolbarButton);
            }
            GUI.skin = null;

            return(true);
        }