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); }
public static SkillObject FsmObjectField(GUIContent label, Skill fsm, SkillObject fsmObject, Type objectTypeConstraint, object[] attributes) { if (label == null) { label = GUIContent.none; } if (fsmObject == null) { SkillObject fsmObject2 = new SkillObject(); fsmObject2.set_ObjectType(objectTypeConstraint); fsmObject = fsmObject2; } EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]); if (!objectTypeConstraint.IsAssignableFrom(fsmObject.get_ObjectType())) { fsmObject.set_ObjectType(objectTypeConstraint); } if (fsmObject.get_UseVariable()) { fsmObject = VariableEditor.DoFsmObjectPopup(label, fsm, fsmObject, objectTypeConstraint); } else { ObjectPropertyDrawer objectPropertyDrawer = ObjectPropertyDrawers.GetObjectPropertyDrawer(fsmObject.get_ObjectType()); if (objectPropertyDrawer != null) { fsmObject.set_Value(objectPropertyDrawer.OnGUI(label, fsmObject.get_Value(), !SkillEditor.SelectedFsmIsPersistent(), attributes)); } else { fsmObject.set_Value(EditorGUILayout.ObjectField(label, fsmObject.get_Value(), fsmObject.get_ObjectType(), !SkillEditor.SelectedFsmIsPersistent(), new GUILayoutOption[0])); } } fsmObject = (SkillObject)VariableEditor.VariableToggle(fsmObject, label.get_text()); VariableEditor.EndVariableEditor(fsmObject); return(fsmObject); }
public static SkillStateAction AddPlaySoundAction(Skill targetFsm, SkillState state, AudioClip audioClip, SkillStateAction beforeAction = null) { SkillStateAction fsmStateAction = ActionUtility.AddAction(state, "HutongGames.PlayMaker.Actions.PlaySound", beforeAction); if (fsmStateAction == null) { return(null); } FieldInfo field = fsmStateAction.GetType().GetField("clip", 20); if (field != null) { FieldInfo arg_38_0 = field; object arg_38_1 = fsmStateAction; SkillObject fsmObject = new SkillObject(); fsmObject.set_Value(audioClip); arg_38_0.SetValue(arg_38_1, fsmObject); } SkillEditor.SetFsmDirty(targetFsm, true, false, true); SkillEditor.SaveActions(targetFsm); return(fsmStateAction); }
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); }