public void InitializeGraph(BaseGraph graph)
        {
            if (this.graph != null && graph != this.graph)
            {
                // Unload the graph
                graphUnloaded?.Invoke(this.graph);
                Resources.UnloadAsset(this.graph);
            }

            graphLoaded?.Invoke(graph);
            this.graph = graph;

            if (graphView != null)
            {
                rootView.Remove(graphView);
            }

            //Initialize will provide the BaseGraphView
            InitializeWindow(graph);

            graphView = rootView.Children().FirstOrDefault(e => e is BaseGraphView) as BaseGraphView;

            if (graphView == null)
            {
                Debug.LogError("GraphView has not been added to the BaseGraph root view !");
                return;
            }

            graphView.Initialize(graph);

            InitializeGraphView(graphView);
        }
        public void InitializeGraph(BaseGraph graph)
        {
            if (this.graph != null && graph != this.graph)
            {
                // Save the graph to the disk
                EditorUtility.SetDirty(this.graph);
                AssetDatabase.SaveAssets();
                // Unload the graph
                graphUnloaded?.Invoke(this.graph);

                if (!this.graph.IsLinkedToScene())
                {
                    Resources.UnloadAsset(this.graph);
                }
            }

            graphLoaded?.Invoke(graph);
            this.graph = graph;

            if (graphView != null)
            {
                rootView.Remove(graphView);
            }

            //Initialize will provide the BaseGraphView
            InitializeWindow(graph);

            graphView = rootView.Children().FirstOrDefault(e => e is BaseGraphView) as BaseGraphView;

            if (graphView == null)
            {
                Debug.LogError("GraphView has not been added to the BaseGraph root view !");
                return;
            }

            graphView.Initialize(graph);

            InitializeGraphView(graphView);

            // TOOD: onSceneLinked...

            if (graph.IsLinkedToScene())
            {
                LinkGraphWindowToScene(graph.GetLinkedScene());
            }
            else
            {
                graph.onSceneLinked += LinkGraphWindowToScene;
            }
        }
        /// <summary>
        /// 只有两种情况会调用到这个函数
        /// 1.打开GraphEditorWindow(初次打开或者在已经打开的基础上更换GraphAsset)
        /// 2.编译/进入PlayMode而导致的GraphEditorWindow重载
        /// </summary>
        /// <param name="graph"></param>
        public void InitializeGraph(BaseGraph graph)
        {
            if (this.graph != null && graph != this.graph)
            {
                // Save the graph to the disk
                GraphCreateAndSaveHelper.SaveGraphToDisk(this.graph);
                // Unload the graph
                graphUnloaded?.Invoke(this.graph);
            }

            graphLoaded?.Invoke(graph);
            this.graph = graph;

            if (graphView != null)
            {
                rootView.Remove(graphView);
            }

            InitializeWindow(graph);
            rootView.Add(graphView);

            graphView = rootView.Children().FirstOrDefault(e => e is BaseGraphView) as BaseGraphView;

            if (graphView == null)
            {
                Debug.LogError("GraphView has not been added to the BaseGraph root view !");
                return;
            }

            graphView.Initialize(graph);

            InitializeGraphView(graphView);

            // TOOD: onSceneLinked...

            if (graph.IsLinkedToScene())
            {
                LinkGraphWindowToScene(graph.GetLinkedScene());
            }
            else
            {
                graph.onSceneLinked += LinkGraphWindowToScene;
            }
            //防止在外部调用InitializeGraph时重复执行InitializeGraph
            reloadWorkaround = false;
        }
        public void InitializeGraph(BaseGraph graph)
        {
            this.graph = graph;

            if (graphView != null)
            {
                rootView.Remove(graphView);
            }

            //Initialize will provide the BaseGraphView
            Initialize(graph);

            graphView = rootView.Children().FirstOrDefault(e => e is BaseGraphView) as BaseGraphView;

            if (graphView == null)
            {
                Debug.LogError("GraphView has not been added to the BaseGraph root view !");
                return;
            }

            graphView.Initialize(graph);
        }