private static void AddSetPropertyAction() { Type actionType = ActionData.GetActionType("HutongGames.PlayMaker.Actions.SetProperty"); if (actionType == null) { Dialogs.MissingAction("Set Property"); return; } SkillStateAction fsmStateAction = SkillEditor.Builder.InsertAction(SkillEditorMacros.droppedOnState, actionType, SkillEditorMacros.droppedOnAction); FieldInfo field = actionType.GetField("targetProperty", 20); if (field != null) { FieldInfo arg_6B_0 = field; object arg_6B_1 = fsmStateAction; SkillProperty fsmProperty = new SkillProperty(); SkillProperty arg_5E_0 = fsmProperty; SkillObject fsmObject = new SkillObject(); fsmObject.set_Value(SkillEditorMacros.droppedObject); arg_5E_0.TargetObject = fsmObject; fsmProperty.setProperty = true; arg_6B_0.SetValue(arg_6B_1, fsmProperty); } SkillEditor.SetFsmDirty(SkillEditorMacros.droppedOnFsm, true, false, true); SkillEditor.SaveActions(SkillEditorMacros.droppedOnFsm); }
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 } } }
public static SkillStateAction AddAction(SkillState state, string actionTypeName, SkillStateAction beforeAction = null) { Type actionType = ActionData.GetActionType(actionTypeName); if (actionType == null) { Debug.LogError(string.Format(Strings.get_ActionUtility_AddAction_Missing_Action(), actionTypeName)); return(null); } return(SkillEditor.Builder.InsertAction(state, actionType, beforeAction)); }