Example #1
0
        /**
         * Called every frame.
         */
        private static void Update()
        {
            // Reinitialize modified fsms and repaint all if some fsms were modified.
            foreach (PlayMakerFSM playMakerFSM in m_dirtyPlayMakerFSMs)
            {
                playMakerFSM.Fsm.Reinitialize();
            }
            m_dirtyPlayMakerFSMs.Clear();
            if (m_fsmEditorDirty)
            {
                m_fsmEditorDirty = false;
                EditorCommands.UpdateGraphView();
                FsmEditor.SetFsmDirty();
                FsmEditor.RepaintAll();
            }

            // Lock all fsms that were temporarily unlocked before saving the scene.
            if (m_unlockedPlayMakerFSMs.Count > 0)
            {
                LockAllFsms();
            }

            // Lock all fsms that are on a locked game object.
            foreach (PlayMakerFSM playMakerFSM in m_playMakerFSMsToBeLocked)
            {
                LockFsm(playMakerFSM);
            }
            m_playMakerFSMsToBeLocked.Clear();
        }
        private static IEnumerator SaveAllTemplates()
        {
            feedback.StartProcedure("Re-Saving All Templates");

            feedback.LogAction("Rebuild Fsm List");

            FsmEditorUtility.BuildTemplateList();

            yield return(null);

            foreach (var template in FsmEditorUtility.TemplateList)
            {
                try
                {
                    feedback.LogAction("Set Fsm Dirty" + template.fsm.Name);
                    FsmEditor.SetFsmDirty(template.fsm, false);
                    feedback.LogAction("Re-save Template: " + template.name);
                }catch (Exception e)
                {
                    Debug.LogWarning("error : " + e.Message);
                }
            }

            feedback.EndProcedure("Re-Saving All Templates");
        }
Example #3
0
        private static void UpdateGetSetPropertyActions()
        {
            var getPropertyActionType = ActionData.GetActionType("HutongGames.PlayMaker.Actions.GetProperty");
            var setPropertyActionType = ActionData.GetActionType("HutongGames.PlayMaker.Actions.SetProperty");

            FsmEditor.RebuildFsmList();

            foreach (var fsm in FsmEditor.FsmList)
            {
                if (fsm.GameObject == null)
                {
                    continue;
                }         // can't update property paths without GameObject

                var upgraded = false;
                foreach (var state in fsm.States)
                {
                    foreach (var action in state.Actions)
                    {
                        var actionType = action.GetType();
                        if (actionType == getPropertyActionType)
                        {
                            var targetPropertyField = getPropertyActionType.GetField("targetProperty", BindingFlags.Public | BindingFlags.Instance);
                            if (targetPropertyField != null)
                            {
                                upgraded |= TryUpgradeFsmProperty(fsm.GameObject, targetPropertyField.GetValue(action) as FsmProperty);
                            }
                        }
                        else if (actionType == setPropertyActionType)
                        {
                            var targetPropertyField = setPropertyActionType.GetField("targetProperty", BindingFlags.Public | BindingFlags.Instance);
                            if (targetPropertyField != null)
                            {
                                upgraded |= TryUpgradeFsmProperty(fsm.GameObject, targetPropertyField.GetValue(action) as FsmProperty);
                            }
                        }
                    }
                }
                if (upgraded)
                {
                    //Undo called in batch operation seems to crash Unity
                    //FsmEditor.SaveActions(fsm);

                    foreach (var state in fsm.States)
                    {
                        state.SaveActions();
                    }

                    FsmEditor.SetFsmDirty(fsm, true);

#if !UNITY_PRE_5_3
                    UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(fsm.Owner.gameObject.scene);
#elif !UNITY_PRE_5_0
                    // Not sure if we need to do this...?
                    UnityEditor.EditorApplication.MarkSceneDirty();
#endif
                }
            }
        }