Beispiel #1
0
        public override void DrawInspector()
        {
            GUI.color = new Color(1, 0.75f, 0.5f);
            if (GUILayout.Button("Open Editor", GUILayout.Height(40)))
            {
                if (DashEditorCore.EditorConfig.editingController != null)
                {
                    DashEditorCore.EditController(DashEditorCore.EditorConfig.editingController,
                                                  GraphUtils.AddChildPath(DashEditorCore.EditorConfig.editingGraphPath, Model.id));
                }
                else
                {
                    DashEditorCore.EditGraph(DashEditorCore.EditorConfig.editingRootGraph,
                                             GraphUtils.AddChildPath(DashEditorCore.EditorConfig.editingGraphPath, Model.id));
                }
            }

            GUI.color = Color.white;

            if (!Model.useAsset)
            {
                if (GUILayout.Button("Save to Asset"))
                {
                    DashGraph graph = GraphUtils.CreateGraphAsAssetFile(SubGraph);
                    if (graph != null)
                    {
                        Model.useAsset   = true;
                        Model.graphAsset = graph;

                        _subGraphInstance   = null;
                        _selfReferenceIndex = -1;
                        _boundSubGraphData  = null;
                        _boundSubGraphReferences.Clear();
                    }
                }
            }
            else
            {
                if (GUILayout.Button("Bind Graph"))
                {
                    DashGraph graph = SubGraph.Clone();
                    _boundSubGraphData  = graph.SerializeToBytes(DataFormat.Binary, ref _boundSubGraphReferences);
                    _selfReferenceIndex = _boundSubGraphReferences.FindIndex(r => r == graph);

                    Model.useAsset   = false;
                    Model.graphAsset = null;
                }
            }

            GUI.color = Color.white;

            base.DrawInspector();
        }
Beispiel #2
0
        public void StopPreview()
        {
            DashTween.CleanAll();
            DashTweenCore.Uninitialize();
            DashCore.Instance.CleanPrefabPools();
            DashCore.Instance.CleanSequencers();

            EditorApplication.update -= OnUpdate;

            if (!_isPreviewing)
            {
                return;
            }

            _isPreviewing = false;

            if (_stage == null)
            {
                // Since we can do almost anything in preview we need to reload the scene before it
                EditorSceneManager.OpenScene(EditorSceneManager.GetActiveScene().path);

                DashController[] controllers = GameObject.FindObjectsOfType <DashController>();
                DashController   controller  = controllers.ToList().Find(c => c.previewing);
                DashEditorCore.EditController(controller, DashEditorCore.EditorConfig.editingGraphPath);
                controller.previewing = false;

                EditorUtility.SetDirty(controller);
                EditorSceneManager.SaveOpenScenes();

                Selection.activeGameObject = controller.gameObject;
            }
            else
            {
                _stage.GetType().GetMethod("ReloadStage", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(_stage, new object[] {});

                DashController[] controllers = _stage.prefabContentsRoot.GetComponentsInChildren <DashController>();
                DashController   controller  = controllers.ToList().Find(c => c.previewing);
                DashEditorCore.EditController(controller, DashEditorCore.EditorConfig.editingGraphPath);
                controller.previewing = false;
                if (_controllerSelected)
                {
                    Selection.objects = new Object[] { controller.gameObject };
                }

                bool state = (bool)_stage.GetType().GetMethod("SavePrefab", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(_stage, new object[] {});
            }
        }