public static SkillStateAction AddPlayAnimationAction(Skill targetFsm, SkillState state, AnimationClip anim, SkillStateAction beforeAction = null) { SkillStateAction fsmStateAction = ActionUtility.AddAction(state, "HutongGames.PlayMaker.Actions.PlayAnimation", beforeAction); if (fsmStateAction == null) { return(null); } if (!ActionUtility.GameObjectHasAnimationClip(targetFsm.get_GameObject(), anim.get_name()) && Dialogs.YesNoDialog(Strings.get_ActionUtility_Add_Animation_Clip_to_GameObject())) { ActionUtility.AddAnimationClip(targetFsm.get_GameObject(), anim); } FieldInfo field = fsmStateAction.GetType().GetField("animName", 20); if (field != null) { FieldInfo arg_68_0 = field; object arg_68_1 = fsmStateAction; SkillString fsmString = new SkillString(); fsmString.set_Value(anim.get_name()); arg_68_0.SetValue(arg_68_1, fsmString); } SkillEditor.SetFsmDirty(targetFsm, true, false, true); SkillEditor.SaveActions(targetFsm); return(fsmStateAction); }
public static SkillString FsmStringField(GUIContent label, Skill fsm, SkillString fsmString, object[] attributes) { if (fsmString.get_UseVariable()) { EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]); fsmString = VariableEditor.DoFsmStringPopup(label, fsm, fsmString); } else { if (fsmString.get_Value() == null) { fsmString.set_Value(string.Empty); } EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]); UIHint uIHint = CustomAttributeHelpers.GetUIHint(attributes); switch (uIHint) { case 1: { GUILayout.BeginVertical(new GUILayoutOption[0]); GUILayout.Label(label, new GUILayoutOption[0]); Rect rect = GUILayoutUtility.GetRect(SkillEditorContent.TempContent(fsmString.get_Value(), ""), SkillEditorStyles.TextArea, new GUILayoutOption[] { GUILayout.MinHeight(44f) }); rect.set_width(340f); fsmString.set_Value(EditorGUI.TextArea(rect, fsmString.get_Value())); GUILayout.EndVertical(); goto IL_363; } case 2: fsmString.set_Value(ActionEditor.EditComponentName(label, fsmString.get_Value(), typeof(Behaviour))); goto IL_363; case 3: fsmString.set_Value(ActionEditor.EditComponentName(label, fsmString.get_Value(), typeof(MonoBehaviour))); ActionEditor.TrySetBehaviourContext(fsmString.get_Value()); goto IL_363; case 4: fsmString.set_Value(ActionEditor.EditMethodName(label, fsmString.get_Value(), false)); goto IL_363; case 6: fsmString.set_Value(EditorGUILayout.TextField(label, fsmString.get_Value(), new GUILayoutOption[0])); ActionEditor.AnimationNamePopup(fsmString); goto IL_363; case 7: fsmString.set_Value(EditorGUILayout.TagField(label, fsmString.get_Value(), new GUILayoutOption[0])); goto IL_363; case 8: StringEditor.LayerNamePopup(label, fsmString, null, null); goto IL_363; case 11: { fsmString.set_Value(EditorGUILayout.TextField(label, fsmString.get_Value(), new GUILayoutOption[0])); EditorGUI.BeginChangeCheck(); string text = SkillEditorGUILayout.ScriptListPopup(); if (EditorGUI.EndChangeCheck() && text != "") { fsmString.set_Value(text); goto IL_363; } goto IL_363; } case 15: fsmString.set_Value(EditorGUILayout.TextField(label, fsmString.get_Value(), new GUILayoutOption[0])); ActionEditor.FsmNamePopup(fsmString); goto IL_363; case 16: fsmString.set_Value(ActionEditor.EditFsmEvent(label, fsmString.get_Value())); goto IL_363; case 17: case 18: case 19: case 20: case 21: case 22: case 23: case 24: case 25: case 26: case 27: case 28: case 29: case 30: case 31: fsmString.set_Value(EditorGUILayout.TextField(label, fsmString.get_Value(), new GUILayoutOption[0])); ActionEditor.VariablePopup(fsmString, uIHint); goto IL_363; case 32: fsmString.set_Value(EditorGUILayout.TextField(label, fsmString.get_Value(), new GUILayoutOption[0])); ActionEditor.AnimatorFloatPopup(fsmString); goto IL_363; case 33: fsmString.set_Value(EditorGUILayout.TextField(label, fsmString.get_Value(), new GUILayoutOption[0])); ActionEditor.AnimatorBoolPopup(fsmString); goto IL_363; case 34: fsmString.set_Value(EditorGUILayout.TextField(label, fsmString.get_Value(), new GUILayoutOption[0])); ActionEditor.AnimatorIntPopup(fsmString); goto IL_363; case 35: fsmString.set_Value(EditorGUILayout.TextField(label, fsmString.get_Value(), new GUILayoutOption[0])); ActionEditor.AnimatorTriggerPopup(fsmString); goto IL_363; case 36: StringEditor.SortingLayerNamePopup(label, fsmString, null, null); goto IL_363; } fsmString.set_Value(EditorGUILayout.TextField(label, fsmString.get_Value(), new GUILayoutOption[0])); } IL_363: fsmString = (SkillString)VariableEditor.VariableToggle(fsmString, label.get_text()); VariableEditor.EndVariableEditor(fsmString); return(fsmString); }
private static object TryConvertValue(Type fieldType, object currentValue, object value) { if (value == null) { return(null); } Type type = value.GetType(); if (fieldType == typeof(GameObject)) { if (type.IsSubclassOf(typeof(Component))) { return(((Component)value).get_gameObject()); } } else { if (fieldType == typeof(SkillGameObject)) { if (type == typeof(GameObject)) { return(new SkillGameObject(value as GameObject)); } if (type.IsSubclassOf(typeof(Component))) { return(new SkillGameObject(((Component)value).get_gameObject())); } } else { if (fieldType == typeof(SkillOwnerDefault)) { if (type == typeof(GameObject)) { SkillOwnerDefault fsmOwnerDefault = new SkillOwnerDefault(); fsmOwnerDefault.set_OwnerOption(1); fsmOwnerDefault.set_GameObject(value as GameObject); return(fsmOwnerDefault); } if (type.IsSubclassOf(typeof(Component))) { GameObject gameObject = ((Component)value).get_gameObject(); if (gameObject != SkillEditor.SelectedFsmGameObject) { SkillOwnerDefault fsmOwnerDefault2 = new SkillOwnerDefault(); fsmOwnerDefault2.set_OwnerOption(1); fsmOwnerDefault2.set_GameObject(gameObject); return(fsmOwnerDefault2); } return(new SkillOwnerDefault()); } } else { if (fieldType == typeof(SkillProperty)) { SkillProperty fsmProperty = currentValue as SkillProperty; SkillProperty fsmProperty2 = new SkillProperty(); SkillProperty arg_14D_0 = fsmProperty2; SkillObject fsmObject = new SkillObject(); fsmObject.set_Value(value as Object); arg_14D_0.TargetObject = fsmObject; fsmProperty2.setProperty = (fsmProperty != null && fsmProperty.setProperty); return(fsmProperty2); } if (fieldType == typeof(SkillObject)) { SkillObject fsmObject2 = new SkillObject(); fsmObject2.set_Value(value as Object); return(fsmObject2); } if (fieldType == typeof(SkillMaterial)) { SkillMaterial fsmMaterial = new SkillMaterial(); fsmMaterial.set_Value(value as Material); return(fsmMaterial); } if (fieldType == typeof(SkillTexture)) { SkillTexture fsmTexture = new SkillTexture(); fsmTexture.set_Value(value as Texture); return(fsmTexture); } if (fieldType == typeof(SkillEventTarget)) { if (type == typeof(PlayMakerFSM)) { return(new SkillEventTarget { target = 3, fsmComponent = value as PlayMakerFSM }); } if (type == typeof(GameObject)) { SkillEventTarget fsmEventTarget = new SkillEventTarget(); fsmEventTarget.target = 1; SkillEventTarget arg_253_0 = fsmEventTarget; SkillOwnerDefault fsmOwnerDefault3 = new SkillOwnerDefault(); fsmOwnerDefault3.set_OwnerOption(1); fsmOwnerDefault3.set_GameObject(value as GameObject); arg_253_0.gameObject = fsmOwnerDefault3; return(fsmEventTarget); } } else { if (fieldType == typeof(SkillString)) { if (type == typeof(PlayMakerFSM)) { SkillString fsmString = new SkillString(); fsmString.set_Value(((PlayMakerFSM)value).get_FsmName()); return(fsmString); } if (type == typeof(AnimationClip)) { SkillString fsmString2 = new SkillString(); fsmString2.set_Value(((AnimationClip)value).get_name()); return(fsmString2); } } } } } } return(value); }