Пример #1
0
        public void OnGUI()
        {
            cache.AssureCanvas();
            NodeEditor.checkInit(true);
            if (NodeEditor.InitiationError)
            {
                GUILayout.Label("Initiation failed! Check console for more information!");
                return;
            }

            try
            {
                GUI.BeginGroup(screenSize? screenRect : specifiedRootRect, NodeEditorGUI.nodeSkin.box);
                NodeEditorGUI.StartNodeGUI();

                canvasRect                   = screenSize? screenRect : specifiedCanvasRect;
                canvasRect.width            -= 200;
                cache.editorState.canvasRect = canvasRect;
                NodeEditor.DrawCanvas(cache.nodeCanvas, cache.editorState);

                GUILayout.BeginArea(new Rect(canvasRect.x + cache.editorState.canvasRect.width, cache.editorState.canvasRect.y, 200, cache.editorState.canvasRect.height), NodeEditorGUI.nodeSkin.box);
                SideGUI();
                GUILayout.EndArea();

                NodeEditorGUI.EndNodeGUI();
                GUI.EndGroup();
            }
            catch (UnityException e)
            {             // on exceptions in drawing flush the canvas to avoid locking the ui.
                cache.NewNodeCanvas();
                NodeEditor.ReInit(true);
                Debug.LogError("Unloaded Canvas due to exception in Draw!");
                Debug.LogException(e);
            }
        }
Пример #2
0
    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();
    }
        private void OnGUI()
        {
            // Initiation
            NodeEditor.checkInit(true);
            if (NodeEditor.InitiationError || canvasCache == null)
            {
                GUILayout.Label("Node Editor Initiation failed! Check console for more information!");
                return;
            }
            AssureEditor();
            canvasCache.AssureCanvas();

            // Specify the Canvas rect in the EditorState, currently disabled for dynamic sidebar resizing
            // canvasCache.editorState.canvasRect = canvasWindowRect;
            // If you want to use GetRect:
//			Rect canvasRect = GUILayoutUtility.GetRect (600, 600);
//			if (Event.current.type != EventType.Layout)
//				mainEditorState.canvasRect = canvasRect;
            NodeEditorGUI.StartNodeGUI("NodeEditorWindow", true);

            canvasCache.editorState.canvasRect = canvasWindowRect;

            // Perform drawing with error-handling
            try
            {
                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 Toolbar
            DrawToolbarGUI();

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

            if (showModalPanel)
            {
                BeginWindows();
                modalWindowRect = GUILayout.Window(0, modalWindowRect, DoModalWindow, "Save to Scene");
                EndWindows();
            }

            NodeEditorGUI.EndNodeGUI();
        }
Пример #4
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();
        }
Пример #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();

            // 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();
        }
Пример #6
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();
    }
Пример #8
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();
        }
Пример #10
0
        private void OnGUI()
        {
/*
 *          if (NodeEditor.curEditorState == null)
 *          {
 *              Debug.Log("OnGUI::TWWindow has no editor state " + NodeEditor.curEditorState+"actual editor state "+ canvasCache.editorState);
 *          }
 *          else if (NodeEditor.curEditorState.selectedNode == null)
 *          {
 *              Debug.Log("OnGUI::TWWindow has no Selected Node " + NodeEditor.curEditorState);
 *          }
 *          else
 *          {
 *              Debug.Log("OnGUI:: Selected Node " + NodeEditor.curEditorState.selectedNode);
 *          }
 */
            // Initiation
            NodeEditor.checkInit(true);
            if (NodeEditor.InitiationError)
            {
                GUILayout.Label("Node Editor Initiation failed! Check console for more information!");
                return;
            }
            AssureEditor();
            canvasCache.AssureCanvas();

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

            // Perform drawing with error-handling
            try
            {
                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 Side Window
            //sideWindowWidth = Math.Min(600, Math.Max(200, (int)(position.width / 5)));
            //GUILayout.BeginArea(sideWindowRect, GUI.skin.box);
            //DrawSideWindow();
            //GUILayout.EndArea();


            NodeEditorGUI.EndNodeGUI();
//            if (Event.current.type == EventType.Repaint)
//                m_InspectorWindow.Repaint();

/*
 *          //if (Event.current.type == EventType.Repaint)
 *          {
 *              if (mainEditorState.selectedNode != mainEditorState.wantselectedNode)
 *              {
 *                  mainEditorState.selectedNode = mainEditorState.wantselectedNode;
 *                  NodeEditor.RepaintClients();
 *                  Repaint();
 *              }
 *
 *          }
 */
            if (!m_Docked)
            {
                Docker.Dock(this, m_InspectorWindow, Docker.DockPosition.Right);
                Docker.Dock(this, m_NodeSelectionWindow, Docker.DockPosition.Left);
                m_Docked = true;
            }
        }
Пример #11
0
        public void DrawToolbarGUI(Rect rect)
        {
            rect.height = toolbarHeight;
            GUILayout.BeginArea(rect, NodeEditorGUI.toolbar);
            GUILayout.BeginHorizontal();
            float curToolbarHeight = 0;

            //RPGTalk removed to make it more simple to use only RPGTalk functions.

            if (GUILayout.Button("New File", NodeEditorGUI.toolbarButton, GUILayout.Width(70)))
            {
                if (EditorUtility.DisplayDialog("Are you sure you want to create a new canvas?", "Any unsaved changes on this one will be lost", "I'm sure", "Hold up..."))
                {
                    canvasCache.NewNodeCanvas(typeof(RPGTalkNodeCanvas));
                }
            }

            if (GUILayout.Button("Load TXT", NodeEditorGUI.toolbarButton, GUILayout.Width(70)))
            {
                if (EditorUtility.DisplayDialog("Are you sure you want to load a new canvas?", "Any unsaved changes on this one will be lost", "I'm sure", "Hold up..."))
                {
                    LoadTXTFile();
                }
            }

            if (GUILayout.Button("Save TXT", NodeEditorGUI.toolbarButton, GUILayout.Width(70)))
            {
                SaveTXTFile();
            }

            //RPGTalk commented to make the interface more simple to the end user

            /*
             * if (GUILayout.Button("File", NodeEditorGUI.toolbarDropdown, GUILayout.Width(50)))
             *          {
             *                  GenericMenu menu = new GenericMenu(!Application.isPlaying);
             *
             *                  // New Canvas filled with canvas types
             *                  NodeCanvasManager.FillCanvasTypeMenu(ref menu, NewNodeCanvas, "New Canvas/");
             *                  menu.AddSeparator("");
             *
             *  menu.AddItem(new GUIContent("Save TXT"), false, SaveTXTFile);
             *
             *
             *
             *
             *
             *
             *  // Load / Save
             #if UNITY_EDITOR
             *  menu.AddItem(new GUIContent("Load Canvas"), false, LoadCanvas);
             *                  menu.AddItem(new GUIContent("Reload Canvas"), false, ReloadCanvas);
             *                  menu.AddSeparator("");
             *                  if (canvasCache.nodeCanvas.allowSceneSaveOnly)
             *                  {
             *                          menu.AddDisabledItem(new GUIContent("Save Canvas"));
             *                          menu.AddDisabledItem(new GUIContent("Save Canvas As"));
             *                  }
             *                  else
             *                  {
             *                          menu.AddItem(new GUIContent("Save Canvas"), false, SaveCanvas);
             *                          menu.AddItem(new GUIContent("Save Canvas As"), false, SaveCanvasAs);
             *                  }
             *                  menu.AddSeparator("");
             #endif
             *
             *                  // Import / Export filled with import/export types
             *                  ImportExportManager.FillImportFormatMenu(ref menu, ImportCanvasCallback, "Import/");
             *                  if (canvasCache.nodeCanvas.allowSceneSaveOnly)
             *                  {
             *                          menu.AddDisabledItem(new GUIContent("Export"));
             *                  }
             *                  else
             *                  {
             *                          ImportExportManager.FillExportFormatMenu(ref menu, ExportCanvasCallback, "Export/");
             *                  }
             *                  menu.AddSeparator("");
             *
             *                  // Scene Saving
             *                  string[] sceneSaves = NodeEditorSaveManager.GetSceneSaves();
             *                  if (sceneSaves.Length <= 0) // Display disabled item
             *                          menu.AddItem(new GUIContent("Load Canvas from Scene"), false, null);
             *                  else foreach (string sceneSave in sceneSaves) // Display scene saves to load
             *                                  menu.AddItem(new GUIContent("Load Canvas from Scene/" + sceneSave), false, LoadSceneCanvasCallback, sceneSave);
             *                  menu.AddItem(new GUIContent("Save Canvas to Scene"), false, SaveSceneCanvasCallback);
             *
             *                  // Show dropdown
             *                  menu.Show(new Vector2(5, toolbarHeight));
             *          }*/
            curToolbarHeight = Mathf.Max(curToolbarHeight, GUILayoutUtility.GetLastRect().yMax);

            GUILayout.Space(10);
            GUILayout.FlexibleSpace();

            //RPGTalk removed to make it more simple

            /*GUILayout.Label(new GUIContent("" + canvasCache.nodeCanvas.saveName + " (" + (canvasCache.nodeCanvas.livesInScene ? "Scene Save" : "Asset Save") + ")",
             *                                                              "Opened Canvas path: " + canvasCache.nodeCanvas.savePath), NodeEditorGUI.toolbarLabel);
             * GUILayout.Label("Type: " + canvasCache.typeData.DisplayString, NodeEditorGUI.toolbarLabel);
             * curToolbarHeight = Mathf.Max(curToolbarHeight, GUILayoutUtility.GetLastRect().yMax);
             *
             * GUI.backgroundColor = new Color(1, 0.3f, 0.3f, 1);
             * if (GUILayout.Button("Force Re-init", NodeEditorGUI.toolbarButton, GUILayout.Width(100)))
             * {
             *      NodeEditor.ReInit(true);
             *      canvasCache.nodeCanvas.Validate();
             * } */
#if !UNITY_EDITOR
            GUILayout.Space(5);
            if (GUILayout.Button("Quit", NodeEditorGUI.toolbarButton, GUILayout.Width(100)))
            {
                Application.Quit();
            }
#endif
            curToolbarHeight    = Mathf.Max(curToolbarHeight, GUILayoutUtility.GetLastRect().yMax);
            GUI.backgroundColor = Color.white;

            GUILayout.EndHorizontal();
            GUILayout.EndArea();
            if (Event.current.type == EventType.Repaint)
            {
                toolbarHeight = curToolbarHeight;
            }
        }
Пример #12
0
 private void NewNodeCanvas(Type canvasType)
 {
     canvasCache.NewNodeCanvas(canvasType);
 }
        private void OnGUI()
        {
            if (wwwShader1 != null)
            {
                if (wwwShader1.isDone)
                {
                    string pathShader = "Assets/TextureWang/Shaders/TextureOps.shader";
                    pathShader = pathShader.Replace("/", "" + Path.DirectorySeparatorChar);

                    File.WriteAllBytes(pathShader, wwwShader1.bytes);
                    AssetDatabase.ImportAsset(pathShader, ImportAssetOptions.ForceSynchronousImport);
                    wwwShader1 = null;
                }
                Repaint();
                Debug.Log("repaint 2");
            }

            if (canvasCache.nodeCanvas.m_PreviewAnimation)
            {
                if (m_SW == null)
                {
                    m_SW = Stopwatch.StartNew();
                }
                m_AnimValue += (m_SW.ElapsedMilliseconds - m_LastTime) / 3000.0f;
                if (m_AnimValue < 0)
                {
                    m_AnimValue = 0;
                }
                m_LastTime = m_SW.ElapsedMilliseconds;
                if (m_AnimValue > 1.0f)
                {
                    m_AnimValue = 0.0f;
                }
                foreach (var x in canvasCache.nodeCanvas.nodes)
                {
                    if (x is InputNodeAnimated)
                    {
                        var ina = x as InputNodeAnimated;
                        ina.m_Value.Set(m_AnimValue);
                    }
                }
                NodeEditor.RecalculateAll(canvasCache.nodeCanvas);
                Repaint();
                Debug.Log("repaint 3");
            }
            else
            {
                m_AnimValue = 0;
            }

            if (m_ReplaceNode != null && !OverlayGUI.HasPopupControl() && ms_InputInfo != null)
            {
                NodeEditorInputSystem.ShowContextMenu(ms_InputInfo);
                ms_InputInfo = null;
            }

/*
 *          if (NodeEditor.curEditorState == null)
 *          {
 *              Debug.Log("OnGUI::TWWindow has no editor state " + NodeEditor.curEditorState+"actual editor state "+ canvasCache.editorState);
 *          }
 *          else if (NodeEditor.curEditorState.selectedNode == null)
 *          {
 *              Debug.Log("OnGUI::TWWindow has no Selected Node " + NodeEditor.curEditorState);
 *          }
 *          else
 *          {
 *              Debug.Log("OnGUI:: Selected Node " + NodeEditor.curEditorState.selectedNode);
 *          }
 */
            // Initiation
            NodeEditor.checkInit(true);
            if (NodeEditor.InitiationError)
            {
                GUILayout.Label("Node Editor Initiation failed! Check console for more information!");
                return;
            }
            AssureEditor();
            canvasCache.AssureCanvas();

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

            // Perform drawing with error-handling
            try
            {
                if ((Event.current.keyCode >= KeyCode.A && Event.current.keyCode <= KeyCode.Z) || Event.current.keyCode == KeyCode.Escape)
                {
                    if (Event.current.keyCode == KeyCode.Escape)
                    {
                        PopupMenu.m_NameFilter = "";
                    }
                    else
                    {
                        int    ascii = ((int)Event.current.keyCode - (int)KeyCode.A) + 65;
                        string c     = Char.ConvertFromUtf32(ascii);
                        PopupMenu.m_NameFilter = c;
                    }

                    Debug.Log("m_NameFilter " + PopupMenu.m_NameFilter);
                    OverlayGUI.currentPopup = null;
                    NodeEditorInputInfo inputInfo = new NodeEditorInputInfo(canvasCache.editorState);

                    NodeEditorInputSystem.ShowContextMenu(inputInfo);
                }
                NodeEditor.DrawCanvas(canvasCache.nodeCanvas, canvasCache.editorState);


                if (canvasCache.editorState.selectedNode != null)
                {
                    if (canvasCache.editorState.selectedNode is TextureNode)
                    {
                        var tn = canvasCache.editorState.selectedNode as TextureNode;
                        if (tn.m_RequestRepaint)
                        {
                            tn.m_RequestRepaint = false;
                            Debug.Log("repaint 1");
                            Repaint();
                            m_InspectorWindow.Repaint();
                        }
                    }
                }


                if (wwwShader1 != null)
                {
                    GUI.Label(new Rect(100, 100, 500, 200), "One Time Shader Download in progress...");
                }
            }
            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 (m_PostOnLoadCanvasFixup != null)
            {
//                m_PostOnLoadCanvasFixup.PostOnLoadCanvasFixup();
                m_PostOnLoadCanvasFixup = null;
            }


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


            NodeEditorGUI.EndNodeGUI();
//            if (Event.current.type == EventType.Repaint)
//                m_InspectorWindow.Repaint();

/*
 *          //if (Event.current.type == EventType.Repaint)
 *          {
 *              if (mainEditorState.selectedNode != mainEditorState.wantselectedNode)
 *              {
 *                  mainEditorState.selectedNode = mainEditorState.wantselectedNode;
 *                  NodeEditor.RepaintClients();
 *                  Repaint();
 *              }
 *
 *          }
 */

            if (!m_Docked && m_DockedRetry++ < 100 && m_InspectorWindow != null && m_NodeSelectionWindow != null)
            {
                try
                {
                    m_DockedRetry++;
                    Docker.Dock(this, m_InspectorWindow, Docker.DockPosition.Right);
                    Docker.Dock(this, m_NodeSelectionWindow, Docker.DockPosition.Left);
                }
                catch (Exception ex)
                {
                    Debug.LogError(" Dock failed " + ex);
                }
                m_Docked = true;
            }
        }
        private void OnGUI()
        {
            if (wwwShader1 != null)
            {
                if (wwwShader1.isDone)
                {
                    string pathShader = "Assets/TextureWang/Shaders/TextureOps.shader";
                    pathShader = pathShader.Replace("/", "" + Path.DirectorySeparatorChar);

                    File.WriteAllBytes(pathShader, wwwShader1.bytes);
                    AssetDatabase.ImportAsset(pathShader, ImportAssetOptions.ForceSynchronousImport);
                    wwwShader1 = null;
                }
                Repaint();
            }


            if (m_ReplaceNode != null && !OverlayGUI.HasPopupControl() && ms_InputInfo != null)
            {
                NodeEditorInputSystem.ShowContextMenu(ms_InputInfo);
                ms_InputInfo = null;
            }

/*
 *          if (NodeEditor.curEditorState == null)
 *          {
 *              Debug.Log("OnGUI::TWWindow has no editor state " + NodeEditor.curEditorState+"actual editor state "+ canvasCache.editorState);
 *          }
 *          else if (NodeEditor.curEditorState.selectedNode == null)
 *          {
 *              Debug.Log("OnGUI::TWWindow has no Selected Node " + NodeEditor.curEditorState);
 *          }
 *          else
 *          {
 *              Debug.Log("OnGUI:: Selected Node " + NodeEditor.curEditorState.selectedNode);
 *          }
 */
            // Initiation
            NodeEditor.checkInit(true);
            if (NodeEditor.InitiationError)
            {
                GUILayout.Label("Node Editor Initiation failed! Check console for more information!");
                return;
            }
            AssureEditor();
            canvasCache.AssureCanvas();

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

            // Perform drawing with error-handling
            try
            {
                NodeEditor.DrawCanvas(canvasCache.nodeCanvas, canvasCache.editorState);


                if (canvasCache.editorState.selectedNode != null)
                {
                    if (canvasCache.editorState.selectedNode is TextureNode)
                    {
                        var tn = canvasCache.editorState.selectedNode as TextureNode;
                        if (tn.m_RequestRepaint)
                        {
                            tn.m_RequestRepaint = false;
                            Repaint();
                            m_InspectorWindow.Repaint();
                        }
                    }
                }
                if (wwwShader1 != null)
                {
                    GUI.Label(new Rect(100, 100, 500, 200), "One Time Shader Download in progress...");
                }
            }
            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 (m_PostOnLoadCanvasFixup != null)
            {
//                m_PostOnLoadCanvasFixup.PostOnLoadCanvasFixup();
                m_PostOnLoadCanvasFixup = null;
            }


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


            NodeEditorGUI.EndNodeGUI();
//            if (Event.current.type == EventType.Repaint)
//                m_InspectorWindow.Repaint();

/*
 *          //if (Event.current.type == EventType.Repaint)
 *          {
 *              if (mainEditorState.selectedNode != mainEditorState.wantselectedNode)
 *              {
 *                  mainEditorState.selectedNode = mainEditorState.wantselectedNode;
 *                  NodeEditor.RepaintClients();
 *                  Repaint();
 *              }
 *
 *          }
 */

            if (!m_Docked && m_DockedRetry++ < 100 && m_InspectorWindow != null && m_NodeSelectionWindow != null)
            {
                try
                {
                    m_DockedRetry++;
                    Docker.Dock(this, m_InspectorWindow, Docker.DockPosition.Right);
                    Docker.Dock(this, m_NodeSelectionWindow, Docker.DockPosition.Left);
                }
                catch (Exception ex)
                {
                    Debug.LogError(" Dock failed " + ex);
                }
                m_Docked = true;
            }
        }
Пример #15
0
        private void OnGUI()
        {
            GUI.enabled = !ShowTutorial;
            NodeEditor.NoBuildShader = false;

            if (Event.current.type == EventType.MouseUp && Event.current.button == 0)
            {
                if (NodeEditor.AutoUpdate)
                {
                    NodeEditor.RecalculateFlag = true;
                }
            }

            NodeEditor.checkInit(true);
            if (NodeEditor.InitiationError)
            {
                GUILayout.Label("Shadero Sprite Shader Editor Initiation failed! Check console for more information!");
                return;
            }
            AssureEditor();
            canvasCache.AssureCanvas();

            canvasCache.editorState.canvasRect = canvasWindowRect;

            NodeEditorGUI.StartNodeGUI();

            try
            {
                NodeEditor.DrawCanvas(canvasCache.nodeCanvas, canvasCache.editorState);
            }
            catch (UnityException e)
            { canvasCache.NewNodeCanvas();
              NodeEditor.ReInit(true);
              Debug.LogError("Unloaded Canvas due to an exception during the drawing phase!");
              Debug.LogException(e); }



            if (NodeEditor.NoBuildShader)
            {
                if (!NodeEditor.FlagIsSaved)
                {
                    float x = canvasCache.editorState.panOffset.x + NodeEditor.BuildShaderPosX;
                    float y = canvasCache.editorState.panOffset.y + NodeEditor.BuildShaderPosY;

                    x /= canvasCache.editorState.zoom;
                    y /= canvasCache.editorState.zoom;
                    x -= 110;
                    y -= 20;
                    x += position.width * 0.4f;
                    y += position.height * 0.4f;
                    y += (90 / canvasCache.editorState.zoom);

                    Texture2D preview = ResourceManager.LoadTexture("Help/arrow.png");
                    GUI.DrawTexture(new Rect(x, y, 128, 100), preview);

                    bframecount += Time.fixedDeltaTime * 0.25f;
                    if (bframecount > 1)
                    {
                        bframe++; bframecount = 0;
                    }
                    if (bframe >= 16)
                    {
                        bframe = 0;
                    }


                    preview = ResourceManager.LoadTexture("Help/help_light.png");

                    x -= 420;
                    y -= 100;

                    GUI.DrawTexture(new Rect(x - 24, y - 24, 410 + 48, 363 + 48), preview);


                    if (bframe == 0)
                    {
                        preview = ResourceManager.LoadTexture("Help/Init_build_anm_1.jpg");
                    }
                    if (bframe == 1)
                    {
                        preview = ResourceManager.LoadTexture("Help/Init_build_anm_2.jpg");
                    }
                    if (bframe == 2)
                    {
                        preview = ResourceManager.LoadTexture("Help/Init_build_anm_3.jpg");
                    }
                    if (bframe == 3)
                    {
                        preview = ResourceManager.LoadTexture("Help/Init_build_anm_4.jpg");
                    }
                    if (bframe == 4)
                    {
                        preview = ResourceManager.LoadTexture("Help/Init_build_anm_5.jpg");
                    }
                    if (bframe == 5)
                    {
                        preview = ResourceManager.LoadTexture("Help/Init_build_anm_6.jpg");
                    }
                    if (bframe == 6)
                    {
                        preview = ResourceManager.LoadTexture("Help/Init_build_anm_7.jpg");
                    }
                    if (bframe == 7)
                    {
                        preview = ResourceManager.LoadTexture("Help/Init_build_anm_8.jpg");
                    }
                    if (bframe == 8)
                    {
                        preview = ResourceManager.LoadTexture("Help/Init_build_anm_9.jpg");
                    }
                    if (bframe == 9)
                    {
                        preview = ResourceManager.LoadTexture("Help/Init_build_anm_10.jpg");
                    }
                    if (bframe == 10)
                    {
                        preview = ResourceManager.LoadTexture("Help/Init_build_anm_11.jpg");
                    }
                    if (bframe == 11)
                    {
                        preview = ResourceManager.LoadTexture("Help/Init_build_anm_12.jpg");
                    }
                    if (bframe == 12)
                    {
                        preview = ResourceManager.LoadTexture("Help/Init_build_anm_13.jpg");
                    }
                    if (bframe >= 13)
                    {
                        preview = ResourceManager.LoadTexture("Help/Init_build_anm_14.jpg");
                    }



                    GUI.DrawTexture(new Rect(x, y, 410, 363), preview);
                }
            }

            sideWindowWidth = Math.Min(205, Math.Max(205, (int)(position.width / 5)));
            GUILayout.BeginArea(sideWindowRect, GUI.skin.box);
            DrawSideWindow();
            GUILayout.EndArea();



            if (GUI.Button(new Rect(10, 75, 200, 20), new GUIContent("Help Tutorial")))
            {
                ShowTutorial = !ShowTutorial;
            }

            if (ShowTutorial)
            {
                GUI.enabled = ShowTutorial;
                Texture2D preview = ResourceManager.LoadTexture("Help/tut_back.png");
                float     x       = position.width;
                float     y       = position.height;
                float     sx      = 926;
                float     sy      = 490;
                Rect      r       = new Rect(x / 2 - sx / 2, y / 2 - sy / 2, sx, sy);
                GUI.DrawTexture(r, preview);
                float Bsize   = 127;
                float Bpos    = 60;
                float Bheight = 35;
                if (GUI.Button(new Rect((x / 2 - sx / 2) + 22, (y / 2 + sy / 2) - Bpos, Bsize - 5, Bheight), new GUIContent("1. Basic part 1")))
                {
                    ShowTutorialCurrent = 0;
                }
                if (GUI.Button(new Rect((x / 2 - sx / 2) + 22 + Bsize, (y / 2 + sy / 2) - Bpos, Bsize - 5, Bheight), new GUIContent("2. Basic part 2")))
                {
                    ShowTutorialCurrent = 1;
                }
                if (GUI.Button(new Rect((x / 2 - sx / 2) + 22 + Bsize * 2, (y / 2 + sy / 2) - Bpos, Bsize - 5, Bheight), new GUIContent("3. The UV")))
                {
                    ShowTutorialCurrent = 2;
                }
                if (GUI.Button(new Rect((x / 2 - sx / 2) + 22 + Bsize * 3, (y / 2 + sy / 2) - Bpos, Bsize - 5, Bheight), new GUIContent("4. Use Shader")))
                {
                    ShowTutorialCurrent = 3;
                }
                if (GUI.Button(new Rect((x / 2 - sx / 2) + 22 + Bsize * 4, (y / 2 + sy / 2) - Bpos, Bsize - 5, Bheight), new GUIContent("5. Parameters")))
                {
                    ShowTutorialCurrent = 4;
                }
                if (GUI.Button(new Rect((x / 2 - sx / 2) + 22 + Bsize * 5, (y / 2 + sy / 2) - Bpos, Bsize - 5, Bheight), new GUIContent("6. HDR")))
                {
                    ShowTutorialCurrent = 5;
                }
                if (GUI.Button(new Rect((x / 2 - sx / 2) + 22 + Bsize * 6, (y / 2 + sy / 2) - Bpos, Bsize - 5, Bheight), new GUIContent("OK")))
                {
                    ShowTutorial = !ShowTutorial;
                }
                if (GUI.Button(new Rect(10, 75, 200, 20), new GUIContent("Help Tutorial")))
                {
                    ShowTutorial = !ShowTutorial;
                }

                if (ShowTutorialCurrent == 0)
                {
                    preview = ResourceManager.LoadTexture("Help/tut_img1.jpg");
                }
                if (ShowTutorialCurrent == 1)
                {
                    preview = ResourceManager.LoadTexture("Help/tut_img2.jpg");
                }
                if (ShowTutorialCurrent == 2)
                {
                    preview = ResourceManager.LoadTexture("Help/tut_img3.jpg");
                }
                if (ShowTutorialCurrent == 3)
                {
                    preview = ResourceManager.LoadTexture("Help/tut_img4.jpg");
                }
                if (ShowTutorialCurrent == 4)
                {
                    preview = ResourceManager.LoadTexture("Help/tut_img5.jpg");
                }
                if (ShowTutorialCurrent == 5)
                {
                    preview = ResourceManager.LoadTexture("Help/tut_img6.jpg");
                }
                r.x     += 23;
                r.y     += 53;
                r.width  = 875;
                r.height = 372;
                GUI.DrawTexture(r, preview);
            }

            NodeEditorGUI.EndNodeGUI();
            NodeEditor.NoBuildShaderContext = NodeEditor.NoBuildShader;
        }
 private void NewNodeCanvas(Type canvasType)
 {
     this.AssertSavaCanvasSuccessfully();
     canvasCache.NewNodeCanvas(canvasType);
 }