private static bool AutoOpenCanvas(int instanceID, int line)
        {
            if (Selection.activeObject is NodeCanvas)
            {
                if (Selection.activeObject != null)
                {
                    try
                    {
                        AssureEditor();
                        editorInterface.AssertSavaCanvasSuccessfully();
                        string NodeCanvasPath = AssetDatabase.GetAssetPath(instanceID);
                        NodeCanvasPath = NodeCanvasPath.Replace("/", @"\");
                        _editor.canvasCache.LoadNodeCanvas(NodeCanvasPath);
                        //需要重新为editorInterface绑定canvasCache,所以这里要置空,留给框架底层自行检测然后绑定
                        editorInterface = null;
                        return(true);
                    }
                    catch
                    {
                        Debug.LogError($"打开失败?试试从\"Tools/其他实用工具/多功能可视化编辑器\"打开吧!");
                    }
                }
            }

            return(false);
        }
Пример #2
0
 public static NodeEditorInterface GetInstance()
 {
     if (mIns == null)
     {
         mIns = new NodeEditorInterface();
     }
     return(mIns);
 }
Пример #3
0
 private void AssureSetup()
 {
     canvasCache.AssureCanvas();
     if (editorInterface == null)
     {             // Setup editor interface
         editorInterface             = new NodeEditorInterface();
         editorInterface.canvasCache = canvasCache;
     }
 }
Пример #4
0
        private void AssureSetup()
        {
            if (canvasCache == null)
            {             // Create cache
                canvasCache = new NodeEditorUserCache(Path.GetDirectoryName(AssetDatabase.GetAssetPath(MonoScript.FromScriptableObject(this))));
            }
            canvasCache.AssureCanvas();

            NodeEditorInterface.GetInstance().canvasCache            = canvasCache;
            NodeEditorInterface.GetInstance().ShowNotificationAction = ShowNotification;
        }
        private void OnDestroy()
        {
            editorInterface.AssertSavaCanvasSuccessfully();

            // Unsubscribe from events
            NodeEditor.ClientRepaints -= Repaint;
            NodeEditor.curEditorState  = null;
            NodeEditor.curNodeCanvas   = null;
            editorInterface            = null;
            _editor          = null;
            this.canvasCache = null;
        }
Пример #6
0
        private void OnDestroy()
        {
            // Unsubscribe from events
            NodeEditor.ClientRepaints               -= Repaint;
            EditorLoadingControl.justLeftPlayMode   -= NormalReInit;
            EditorLoadingControl.justOpenedNewScene -= NormalReInit;
            SceneView.onSceneGUIDelegate            -= OnSceneGUI;

            NodeEditorInterface.GetInstance().isOpenedWindows = false;

            // Clear Cache
            canvasCache.ClearCacheEvents();
        }
Пример #7
0
 private void AssureSetup()
 {
     if (canvasCache == null)
     {             // Create cache and load startup-canvas
         canvasCache = new NodeEditorUserCache();
         canvasCache.SetCanvas(NodeEditorSaveManager.CreateWorkingCopy(canvas));
     }
     canvasCache.AssureCanvas();
     if (editorInterface == null)
     {             // Setup editor interface
         editorInterface             = NodeEditorInterface.GetInstance();
         editorInterface.canvasCache = canvasCache;
     }
 }
        private void AssureSetup()
        {
            if (canvasCache == null)
            {
                // Create cache
                canvasCache = new NodeEditorUserCache();
            }

            canvasCache.AssureCanvas();
            if (editorInterface == null)
            {
                // Setup editor interface
                editorInterface                        = new NodeEditorInterface();
                editorInterface.canvasCache            = canvasCache;
                editorInterface.ShowNotificationAction = ShowNotification;
            }
        }
Пример #9
0
        /*
         * /// <summary>
         * /// Assures that the canvas is opened when double-clicking a canvas asset
         * /// </summary>
         * [UnityEditor.Callbacks.OnOpenAsset(1)]
         * private static bool AutoOpenCanvas(int instanceID, int line)
         * {
         *      if (Selection.activeObject != null && Selection.activeObject is NodeCanvas)
         *      {
         *              string NodeCanvasPath = AssetDatabase.GetAssetPath(instanceID);
         *              OpenNodeEditor().canvasCache.LoadNodeCanvas(NodeCanvasPath);
         *              return true;
         *      }
         *      return false;
         * }
         */

        private void OnEnable()
        {
            _editor = this;
            NormalReInit();

            // Subscribe to events
            NodeEditor.ClientRepaints               -= Repaint;
            NodeEditor.ClientRepaints               += Repaint;
            EditorLoadingControl.justLeftPlayMode   -= NormalReInit;
            EditorLoadingControl.justLeftPlayMode   += NormalReInit;
            EditorLoadingControl.justOpenedNewScene -= NormalReInit;
            EditorLoadingControl.justOpenedNewScene += NormalReInit;
            SceneView.onSceneGUIDelegate            -= OnSceneGUI;
            SceneView.onSceneGUIDelegate            += OnSceneGUI;

            NodeEditorInterface.GetInstance().isOpenedWindows = true;
        }
Пример #10
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();
        }
Пример #11
0
        private void AssureSetup()
        {
            if (canvasCache == null)
            {
                AssureCache();
            }
            else if (!AssetDatabase.IsValidFolder(ResourceManager.StripTrailingSeparator(canvasCache.GetCachePath())))
            {
                AssureCache();
            }
            canvasCache.AssureCanvas();

            if (editorInterface == null)
            {             // Setup editor interface
                editorInterface                        = new NodeEditorInterface();
                editorInterface.canvasCache            = canvasCache;
                editorInterface.ShowNotificationAction = ShowNotification;
            }
        }
Пример #12
0
 private void AssureSetup()
 {
     if (canvasCache == null)
     {             // Create cache and load startup-canvas
         canvasCache = new NodeEditorUserCache();
         if (canvas != null)
         {
             canvasCache.SetCanvas(NodeEditorSaveManager.CreateWorkingCopy(canvas));
         }
         else if (!string.IsNullOrEmpty(loadSceneName))
         {
             canvasCache.LoadSceneNodeCanvas(loadSceneName);
         }
     }
     canvasCache.AssureCanvas();
     if (editorInterface == null)
     {             // Setup editor interface
         editorInterface             = new NodeEditorInterface();
         editorInterface.canvasCache = canvasCache;
     }
 }