예제 #1
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[] {});
            }
        }
예제 #2
0
    public static void SavePrefab(PrefabStage prefabStage)
    {
        if (prefabStage == null)
        {
            throw new ArgumentNullException();
        }

        var savePrefabMethod = prefabStage.GetType().GetMethod("SavePrefab", BindingFlags.NonPublic | BindingFlags.Instance);

        if (savePrefabMethod == null)
        {
            throw new InvalidOperationException();
        }

        savePrefabMethod?.Invoke(prefabStage, null);
    }
예제 #3
0
        public void StartPreview(NodeBase p_node)
        {
            // Debug.Log("EditorCore.StartPreview");

            if (Controller == null || _isPreviewing || !Controller.gameObject.activeSelf)
            {
                return;
            }

            _previewNodeIndex = DashEditorCore.EditorConfig.editingGraph.Nodes.IndexOf(p_node);

            _stage = PrefabStageUtility.GetCurrentPrefabStage();

            _controllerSelected = Selection.activeGameObject == Controller.gameObject;

            Controller.previewing = true;
            // Debug.Log("Set controller dirty");
            DashEditorCore.SetDirty();

            if (_stage == null)
            {
                // Debug.Log("Save Open Scenes");
                EditorSceneManager.SaveOpenScenes();
            }
            else
            {
                bool state = (bool)_stage.GetType()
                             .GetMethod("SavePrefab", BindingFlags.Instance | BindingFlags.NonPublic)
                             .Invoke(_stage, new object[] { });
            }

            _isPreviewing   = true;
            _previewStarted = false;

            ExpressionEvaluator.ClearCache();

            // Debug.Log("Fetch Global Variables");
            //VariableUtils.FetchGlobalVariables();

            // Debug.Log("Cloning preview graph");
            _previewGraph = DashEditorCore.EditorConfig.editingGraph.Clone();
            _previewGraph.Initialize(Controller);
            DashEditorCore.EditorConfig.editingGraph = _previewGraph;
            // Debug.Log("Start preview");

            EditorApplication.update += OnUpdate;
        }
예제 #4
0
 public bool GetAutoSave(PrefabStage instance)
 {
     if (instance == null)
     {
         return(false);
     }
     if (dg_get_autoSave == null || dg_get_autoSave.Target != (object)instance)
     {
         dg_get_autoSave = (Func <bool>)Delegate.CreateDelegate(typeof(Func <bool>), instance, instance.GetType().GetProperty("autoSave", BindingFlags.Instance | BindingFlags.NonPublic).GetGetMethod(true));
     }
     return(dg_get_autoSave());
 }