Esempio n. 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);
            }
        }
Esempio n. 2
0
    public void OnGUI()
    {
        if (canvas != null && state != null)
        {
            NodeEditor.checkInit();
            if (NodeEditor.InitiationError)
            {
                GUILayout.Label("Initiation failed! Check console for more information!");
                return;
            }

            try
            {
                //GUI.BeginGroup (rootRect, NodeEditorGUI.nodeSkin.box);

                //GUILayout.FlexibleSpace ();

                //GUI.BeginGroup (subRootRect, NodeEditorGUI.nodeSkin.box);

                state.canvasRect = new Rect(0, 0, Screen.width, Screen.height);
                NodeEditor.DrawCanvas(canvas, state);

                //GUI.EndGroup ();

                //GUI.EndGroup ();
            }
            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);
            }
        }
    }
Esempio n. 3
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();
        }
Esempio n. 5
0
        public void OnGUI()
        {
            if (canvas != null)
            {
                if (state == null)
                {
                    NewEditorState();
                }
                NodeEditor.checkInit(true);
                if (NodeEditor.InitiationError)
                {
                    GUILayout.Label("Initiation failed! Check console for more information!");
                    return;
                }

                try
                {
                    if (!screenSize && specifiedRootRect.max != specifiedRootRect.min)
                    {
                        GUI.BeginGroup(specifiedRootRect, NodeEditorGUI.nodeSkin.box);
                    }

                    NodeEditorGUI.StartNodeGUI();

                    canvasRect        = screenSize? new Rect(0, 0, Screen.width, Screen.height) : specifiedCanvasRect;
                    canvasRect.width -= 200;
                    state.canvasRect  = canvasRect;
                    NodeEditor.DrawCanvas(canvas, state);

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

                    NodeEditorGUI.EndNodeGUI();

                    if (!screenSize && specifiedRootRect.max != specifiedRootRect.min)
                    {
                        GUI.EndGroup();
                    }
                }
                catch (UnityException e)
                {                 // on exceptions in drawing flush the canvas to avoid locking the ui.
                    NewNodeCanvas();
                    NodeEditor.ReInit(true);
                    Debug.LogError("Unloaded Canvas due to exception in Draw!");
                    Debug.LogException(e);
                }
            }
        }
Esempio n. 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();

            // 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();
        }
Esempio n. 7
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();
        }
Esempio n. 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;

            //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();
        }
Esempio n. 9
0
 public void OnGUI()
 {
     if ((Object)canvas != (Object)null)
     {
         if ((Object)state == (Object)null)
         {
             NewEditorState();
         }
         NodeEditor.checkInit(true);
         if (!NodeEditor.InitiationError)
         {
             try
             {
                 if (!screenSize && specifiedRootRect.max != specifiedRootRect.min)
                 {
                     GUI.BeginGroup(specifiedRootRect, NodeEditorGUI.nodeSkin.box);
                 }
                 NodeEditorGUI.StartNodeGUI();
                 canvasRect        = ((!screenSize) ? specifiedCanvasRect : new Rect(0f, 0f, (float)Screen.width, (float)Screen.height));
                 canvasRect.width -= 200f;
                 state.canvasRect  = canvasRect;
                 NodeEditor.DrawCanvas(canvas, state);
                 GUILayout.BeginArea(new Rect(canvasRect.x + state.canvasRect.width, state.canvasRect.y, 200f, state.canvasRect.height), NodeEditorGUI.nodeSkin.box);
                 SideGUI();
                 GUILayout.EndArea();
                 NodeEditorGUI.EndNodeGUI();
                 if (!screenSize && specifiedRootRect.max != specifiedRootRect.min)
                 {
                     GUI.EndGroup();
                 }
             }
             catch (UnityException exception)
             {
                 NewNodeCanvas();
                 NodeEditor.ReInit(true);
                 Debug.LogError("Unloaded Canvas due to exception in Draw!");
                 Debug.LogException(exception);
             }
         }
         else
         {
             GUILayout.Label("Initiation failed! Check console for more information!");
         }
     }
 }
    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();
    }
Esempio n. 11
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();
        }
Esempio n. 12
0
 public override void UpdateView(Rect size, Rect percentageSize, Event e)
 {
     base.UpdateView(size, percentageSize, e);
     ProcessEvent(e);
     GUI.Box(ViewRect, Title, ViewSkin.GetStyle("TriggerEditorCanvas"));
     GUILayout.BeginArea(ViewRect);
     {
         if (e.button == 1 && e.type == EventType.mouseDown)
         {
             menu = NodeEditor.GetGenericMenu();//需要修改 装入InputControls中
             menu.ShowAsContext();
         }
         if (TriggerEditorUtility.CheckInit())
         {
             NodeEditor.DrawCanvas(ViewRect);
         }
     }
     GUILayout.EndArea();
 }
        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();
        }
Esempio n. 14
0
        private void OnGUI()
        {
            // Initiation
            NodeEditor.checkInit(true);
            if (NodeEditor.InitiationError)
            {
                GUILayout.Label("Node Editor Initiation failed! Check console for more information!");
                return;
            }
            AssureEditor();
            AssureCanvas();

            // 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;
            NodeEditorGUI.StartNodeGUI();

            // 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();
                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();
        }
Esempio n. 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 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;
            }
        }
        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;
            }
        }
        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;
            }
        }