Esempio n. 1
0
        public void OnGUI()
        {
            NodeEditor.checkInit();
            AssureHasEditor();
            if (NodeEditor.InitiationError)
            {
                GUILayout.Label("Initiation failed! Check console for more information!");
                return;
            }
            // Example of creating Nodes and Connections through code
            //		CalcNode calcNode1 = CalcNode.Create (new Rect (200, 200, 200, 100));
            //		CalcNode calcNode2 = CalcNode.Create (new Rect (600, 200, 200, 100));
            //		Node.ApplyConnection (calcNode1.Outputs [0], calcNode2.Inputs [0]);

            mainEditorState.canvasRect = canvasWindowRect;
            try
            {
                NodeEditor.DrawCanvas(mainNodeCanvas, mainEditorState, Repaint);
            }
            catch (UnityException e)
            {
                // on exceptions in drawing flush the canvas to avoid locking the ui.
                NewNodeCanvas();
                Debug.LogError("Unloaded Canvas due to exception in Draw!");
                Debug.LogException(e);
            }
            // Draw Side Window
            sideWindowWidth = Math.Min(600, Math.Max(200, (int)(position.width / 5)));
            GUILayout.BeginArea(sideWindowRect, NodeEditor.nodeBox);
            DrawSideWindow();
            GUILayout.EndArea();
        }
Esempio n. 2
0
        public void OnGUI()
        {
            // Initiation
            NodeEditor.checkInit();
            if (NodeEditor.InitiationError)
            {
                GUILayout.Label("Initiation failed! Check console for more information!");
                return;
            }
            AssureHasEditor();
            if (mainNodeCanvas == null)
            {
                NewNodeCanvas();
            }
            //Debug.Log ("mainNodeCanvas " + mainNodeCanvas.name);

            // Specify the Canvas rect in the EditorState
            mainEditorState.canvasRect = canvasWindowRect;
            // If you want to use GetRect:
//			Rect canvasRect = GUILayoutUtility.GetRect (600, 600);
//			if (Event.current.type != EventType.Layout)
//				mainEditorState.canvasRect = canvasRect;

            // Perform drawing with error-handling
            try
            {
                NodeEditor.DrawCanvas(mainNodeCanvas, mainEditorState);
            }
            catch (UnityException e)
            {             // on exceptions in drawing flush the canvas to avoid locking the ui.
                NewNodeCanvas();
                Debug.LogError("Unloaded Canvas due to exception in Draw!");
                Debug.LogException(e);
            }

            // Draw Side Window
            sideWindowWidth = Math.Min(600, Math.Max(200, (int)(position.width / 5)));
            NodeEditorGUI.StartNodeGUI();
            GUILayout.BeginArea(sideWindowRect, GUI.skin.box);
            DrawSideWindow();
            GUILayout.EndArea();
            NodeEditorGUI.EndNodeGUI();
        }