public static void EndNodeGUI()
 {
     OverlayGUI.EndOverlayGUI();
     if ((Object)GUI.skin == (Object)defaultSkin)
     {
         GUI.skin = defaultSkin;
     }
 }
Exemple #2
0
        public override void OnInspectorGUI()
        {
            if (node == null)
            {
                node = (Node)target;
            }
            if (node == null)
            {
                return;
            }
            if (titleStyle == null)
            {
                titleStyle           = new GUIStyle(GUI.skin.label);
                titleStyle.fontStyle = FontStyle.Bold;
                titleStyle.alignment = TextAnchor.MiddleCenter;
                titleStyle.fontSize  = 16;
            }
            if (boldLabelStyle == null)
            {
                boldLabelStyle           = new GUIStyle(GUI.skin.label);
                boldLabelStyle.fontStyle = FontStyle.Bold;
            }

            OverlayGUI.StartOverlayGUI("NodeInspector");

            EditorGUI.BeginChangeCheck();

            GUILayout.Space(10);

            GUILayout.Label(node.Title, titleStyle);

            GUILayout.Space(10);

            GUILayout.Label("Rect: " + node.rect.ToString());
            node.backgroundColor = EditorGUILayout.ColorField("Color", node.backgroundColor);

            GUILayout.Space(10);

            GUILayout.Label("Connection Ports", boldLabelStyle);
            foreach (ConnectionPort port in node.connectionPorts)
            {
                string labelPrefix = port.direction == Direction.In ? "Input " : (port.direction == Direction.Out ? "Output " : "");
                string label       = labelPrefix + port.styleID + " '" + port.name + "'";
                EditorGUILayout.ObjectField(label, port, port.GetType(), true);
            }

            GUILayout.Space(10);

            GUILayout.Label("Property Editor", boldLabelStyle);
            node.DrawNodePropertyEditor();

            if (EditorGUI.EndChangeCheck())
            {
                NodeEditor.RepaintClients();
            }

            OverlayGUI.EndOverlayGUI();
        }
    private void OnGUI()
    {
        float inset = 0.0f;

        Vector3[] corners = new Vector3[4];
        rt.GetWorldCorners(corners);
        Vector3 topLeft = corners[1];

        topLeft.y  = Screen.height - topLeft.y;
        rootRect   = new Rect(topLeft.x, topLeft.y, corners[2].x - corners[0].x, corners[2].y - corners[0].y);
        canvasRect = new Rect(rootRect.x + inset, rootRect.y + inset, rootRect.width - inset * 2, rootRect.height - inset * 2);

        // Initiation
        NodeEditor.checkInit(true);
        if (NodeEditor.InitiationError)
        {
            GUILayout.Label("Node Editor Initiation failed! Check console for more information!");
            return;
        }
        AssureSetup();

        // ROOT: Start Overlay GUI for popups
        OverlayGUI.StartOverlayGUI("RTNodeEditor");

        // Set various nested groups
        GUI.BeginGroup(rootRect, GUI.skin.box);

        // Begin Node Editor GUI and set canvas rect
        NodeEditorGUI.StartNodeGUI(false);
        canvasCache.editorState.canvasRect = new Rect(canvasRect.x, canvasRect.y + editorInterface.toolbarHeight, canvasRect.width, canvasRect.height - editorInterface.toolbarHeight);

        try
        { // Perform drawing with error-handling
            NodeEditor.DrawCanvas(canvasCache.nodeCanvas, canvasCache.editorState);
        }
        catch (UnityException e)
        { // On exceptions in drawing flush the canvas to avoid locking the UI
            canvasCache.NewNodeCanvas();
            NodeEditor.ReInit(true);
            Debug.LogError("Unloaded Canvas due to exception in Draw!");
            Debug.LogException(e);
        }

        // Draw Interface
        editorInterface.DrawToolbarGUI(canvasRect);
        editorInterface.DrawModalPanel();

        // End Node Editor GUI
        NodeEditorGUI.EndNodeGUI();

        // End various nested groups
        GUI.EndGroup();

        // END ROOT: End Overlay GUI and draw popups
        OverlayGUI.EndOverlayGUI();
    }
Exemple #4
0
        /// <summary>
        /// Draws the Node Canvas on the screen in the rect specified by editorState
        /// </summary>
        public static void DrawCanvas(NodeCanvas nodeCanvas, NodeEditorState editorState)
        {
            if (!editorState.drawing)
            {
                return;
            }
            checkInit();

            NodeEditorGUI.StartNodeGUI();
            OverlayGUI.StartOverlayGUI();
            DrawSubCanvas(nodeCanvas, editorState);
            OverlayGUI.EndOverlayGUI();
            NodeEditorGUI.EndNodeGUI();
        }
Exemple #5
0
        private void OnGUI()
        {
            // Initiation
            NodeEditor.checkInit(true);
            if (NodeEditor.InitiationError)
            {
                GUILayout.Label("Node Editor Initiation failed! Check console for more information!");
                return;
            }
            AssureSetup();

            // Start Overlay GUI for popups (before any other GUI)
            OverlayGUI.StartOverlayGUI("RTNodeEditor");

            // Set root rect (can be any number of arbitrary groups, e.g. a nested UI, but at least one)
            GUI.BeginGroup(new Rect(0, 0, Screen.width, Screen.height));

            // Begin Node Editor GUI and set canvas rect
            NodeEditorGUI.StartNodeGUI(false);
            canvasCache.editorState.canvasRect = new Rect(rect.x, rect.y + editorInterface.toolbarHeight, rect.width, rect.height - editorInterface.toolbarHeight);

            try
            {             // Perform drawing with error-handling
                NodeEditor.DrawCanvas(canvasCache.nodeCanvas, canvasCache.editorState);
            }
            catch (UnityException e)
            {             // On exceptions in drawing flush the canvas to avoid locking the UI
                canvasCache.NewNodeCanvas();
                NodeEditor.ReInit(true);
                Debug.LogError("Unloaded Canvas due to exception in Draw!");
                Debug.LogException(e);
            }

            // Draw Interface
            GUILayout.BeginArea(rect);
            editorInterface.DrawToolbarGUI();
            GUILayout.EndArea();
            editorInterface.DrawModalPanel();

            // End Node Editor GUI
            NodeEditorGUI.EndNodeGUI();

            // End root rect
            GUI.EndGroup();

            // End Overlay GUI and draw popups
            OverlayGUI.EndOverlayGUI();
        }
Exemple #6
0
        private void OnGUI()
        {
            // Initiation
            NodeEditor.checkInit(true);
            if (NodeEditor.InitiationError)
            {
                GUILayout.Label("Node Editor Initiation failed! Check console for more information!");
                return;
            }
            AssureSetup();

            // ROOT: Start Overlay GUI for popups
            OverlayGUI.StartOverlayGUI("RTNodeEditor");

            // Set various nested groups
            GUI.BeginGroup(rootRect, GUI.skin.box);

            // Begin Node Editor GUI and set canvas rect
            NodeEditorGUI.StartNodeGUI(false);
            canvasCache.editorState.canvasRect = new Rect(canvasRect.x, canvasRect.y /* + editorInterface.toolbarHeight*/, canvasRect.width, canvasRect.height /* - editorInterface.toolbarHeight*/);

            try
            {             // Perform drawing with error-handling
                NodeEditor.DrawCanvas(canvasCache.nodeCanvas, canvasCache.editorState);
            }
            catch (UnityException e)
            {             // On exceptions in drawing flush the canvas to avoid locking the UI
                canvasCache.NewNodeCanvas();
                NodeEditor.ReInit(true);
                Debug.LogError("Unloaded Canvas due to exception in Draw!");
                Debug.LogException(e);
            }

            //Debug.Log(Event.current.type);
            // Draw Interface
            editorInterface.DrawToolbarGUI(canvasRect);
            editorInterface.DrawModalPanel();

            // End Node Editor GUI
            NodeEditorGUI.EndNodeGUI();

            // End various nested groups
            GUI.EndGroup();

            // END ROOT: End Overlay GUI and draw popups
            OverlayGUI.EndOverlayGUI();
        }
Exemple #7
0
        private void OnGUI()
        {
            // Initiation
            NodeEditor.checkInit(true);
            if (NodeEditor.InitiationError)
            {
                GUILayout.Label("Node Editor Initiation failed! Check console for more information!");
                return;
            }
            AssureEditor();
            AssureSetup();

            // ROOT: Start Overlay GUI for popups
            OverlayGUI.StartOverlayGUI("NodeEditorWindow");

            // Begin Node Editor GUI and set canvas rect
            NodeEditorGUI.StartNodeGUI(true);
            canvasCache.editorState.canvasRect = canvasWindowRect;

            //EditorGUI.BeginChangeCheck();
            try
            { // Perform drawing with error-handling
                NodeEditor.DrawCanvas(canvasCache.nodeCanvas, canvasCache.editorState);
            }
            catch (UnityException e)
            { // On exceptions in drawing flush the canvas to avoid locking the UI
                canvasCache.NewNodeCanvas();
                NodeEditor.ReInit(true);
                Debug.LogError("Unloaded Canvas due to an exception during the drawing phase!");
                Debug.LogException(e);
            }
            //if (EditorGUI.EndChangeCheck())
            //{
            //    Debug.Log("修改文件:" + canvasCache.nodeCanvas.saveName);
            //}

            // Draw Interface
            editorInterface.DrawToolbarGUI(new Rect(0, 0, Screen.width, 0));
            editorInterface.DrawModalPanel();

            // End Node Editor GUI
            NodeEditorGUI.EndNodeGUI();

            // END ROOT: End Overlay GUI and draw popups
            OverlayGUI.EndOverlayGUI();
        }
    private void OnGUI()
    {
        // Initiation
        NodeEditor.checkInit(true);
        if (NodeEditor.InitiationError)
        {
            GUILayout.Label("Node Editor Initiation failed! Check console for more information!");
            return;
        }
        AssureSetup();

        // Start Overlay GUI for popups
        OverlayGUI.StartOverlayGUI("RTNodeEditor");

        // Begin Node Editor GUI and set canvas rect
        NodeEditorGUI.StartNodeGUI(false);
        canvasCache.editorState.canvasRect = new Rect(rect.x, rect.y + editorInterface.toolbarHeight, rect.width, rect.height - editorInterface.toolbarHeight);

        // Access custom state variable whenever you need
        canvasCache.editorState.myCustomStateVariable = 0;

        try
        {         // Perform drawing with error-handling
            NodeEditor.DrawCanvas(canvasCache.nodeCanvas, canvasCache.editorState);
        }
        catch (UnityException e)
        {         // On exceptions in drawing flush the canvas to avoid locking the UI
            canvasCache.NewNodeCanvas();
            NodeEditor.ReInit(true);
            Debug.LogError("Unloaded Canvas due to exception in Draw!");
            Debug.LogException(e);
        }

        // Draw Interface
        GUILayout.BeginArea(rect);
        editorInterface.DrawToolbarGUI();
        GUILayout.EndArea();
        editorInterface.DrawModalPanel();

        // End Node Editor GUI
        NodeEditorGUI.EndNodeGUI();

        // End Overlay GUI and draw popups
        OverlayGUI.EndOverlayGUI();
    }
Exemple #9
0
        private void OnGUI()
        {
            // Initiation
            NodeEditor.checkInit(true);
            if (NodeEditor.InitiationError)
            {
                GUILayout.Label("Node Editor Initiation failed! Check console for more information!");
                return;
            }
            AssureEditor();
            AssureSetup();

            // ROOT: Start Overlay GUI for popups
            OverlayGUI.StartOverlayGUI("NodeEditorWindow");

            // Begin Node Editor GUI and set canvas rect
            NodeEditorGUI.StartNodeGUI(true);
            canvasCache.editorState.canvasRect = canvasWindowRect;

            try
            {             // Perform drawing with error-handling
                NodeEditor.DrawCanvas(canvasCache.nodeCanvas, canvasCache.editorState);
            }
            catch (UnityException e)
            {             // On exceptions in drawing flush the canvas to avoid locking the UI
                canvasCache.NewNodeCanvas();
                NodeEditor.ReInit(true);
                LogMgr.LogError("Unloaded Canvas due to an exception during the drawing phase!");
                LogMgr.LogException(e);
            }


            // Draw Interface
            NodeEditorInterface.GetInstance().DrawToolbarGUI(new Rect(0, 0, Screen.width, 0));
            ActionMenuTools.GetInstance().DrawGamesMenu(Math.Min(400, Math.Max(200, (int)(position.width / 5))), position.height);

            NodeEditorInterface.GetInstance().DrawModalPanel();

            // End Node Editor GUI
            NodeEditorGUI.EndNodeGUI();

            // END ROOT: End Overlay GUI and draw popups
            OverlayGUI.EndOverlayGUI();
        }
        protected override void OnGUI()
        {
            base.OnGUI();

            // Initiation
            NodeEditor.checkInit(true);
            if (NodeEditor.InitiationError)
            {
                GUILayout.Label("Node Editor Initiation failed! Check console for more information!");
                return;
            }
            AssureSetup();

            // ROOT: Start Overlay GUI for popups
            OverlayGUI.StartOverlayGUI("ActorEditorWindow");

            // Begin Node Editor GUI and set canvas rect
            NodeEditorGUI.StartNodeGUI(true);
            _canvasCache.editorState.canvasRect = CanvasWindowRect;

            try
            {
                // Perform drawing with error-handling
                NodeEditor.DrawCanvas(_canvasCache.nodeCanvas, _canvasCache.editorState);
            }
            catch (UnityException e)
            { // On exceptions in drawing flush the canvas to avoid locking the UI
                _canvasCache.NewNodeCanvas();
                NodeEditor.ReInit(true);
                Debug.LogError("Unloaded Canvas due to an exception during the drawing phase!");
                Debug.LogException(e);
            }

            // Draw Interface
            _editorInterface.DrawToolbarGUI(new Rect(MenuWidth - 5, 0, Screen.width - MenuWidth + 5, 30));
            _editorInterface.DrawModalPanel();

            // End Node Editor GUI
            NodeEditorGUI.EndNodeGUI();

            // END ROOT: End Overlay GUI and draw popups
            OverlayGUI.EndOverlayGUI();
        }
 public static void EndNodeGUI()
 {
     OverlayGUI.EndOverlayGUI();
     GUI.skin = defaultSkin;
 }