public void OnDestroyItem() { if (this.spActionsList.objectReferenceValue != null) { IActionsList list = (IActionsList)this.spActionsList.objectReferenceValue; AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(list.gameObject)); AssetDatabase.SaveAssets(); } }
protected void OnEnableBase() { this.targetItem = (IDialogueItem)target; this.spDialogue = this.serializedObject.FindProperty(PROP_DIALOGUE); this.spParent = this.serializedObject.FindProperty(PROP_PARENT); this.spChildren = serializedObject.FindProperty(PROP_CHILDREN); this.spConfig = this.serializedObject.FindProperty(PROP_CONFIG); this.spOverrideConfig = this.serializedObject.FindProperty(PROP_OVERR_CONFIG); this.spExecuteBehavior = serializedObject.FindProperty(PROP_EXECUTE_BEHAVIOR); this.spActionsList = serializedObject.FindProperty(PROP_ACTIONS); if (this.spActionsList.objectReferenceValue == null) { IActionsList actionsList = this.targetItem.gameObject.AddComponent <IActionsList>(); actionsList.hideFlags = HideFlags.HideInInspector; this.spActionsList.objectReferenceValue = actionsList; serializedObject.ApplyModifiedPropertiesWithoutUndo(); serializedObject.Update(); } this.spConditionList = serializedObject.FindProperty(PROP_CONDITIONS); if (this.spConditionList.objectReferenceValue == null) { IConditionsList conditionList = this.targetItem.gameObject.AddComponent <IConditionsList>(); conditionList.hideFlags = HideFlags.HideInInspector; this.spConditionList.objectReferenceValue = conditionList; serializedObject.ApplyModifiedPropertiesWithoutUndo(); serializedObject.Update(); } this.spContent = serializedObject.FindProperty(PROP_CONTENT); this.spContentString = this.spContent.FindPropertyRelative(PROP_CONTENT_STR); this.spVoice = this.serializedObject.FindProperty(PROP_VOICE); this.spAutoPlay = this.serializedObject.FindProperty(PROP_AUTOPLAY); this.spAutoPlayTime = this.serializedObject.FindProperty(PROP_AUTOPLAY_TIME); this.spActor = this.serializedObject.FindProperty(PROP_ACTOR); this.spActorSpriteIndex = this.serializedObject.FindProperty(PROP_ACTOR_SPRITE); this.spActorTransform = this.serializedObject.FindProperty(PROP_ACTOR_TRANSFORM); this.spAfterRun = this.serializedObject.FindProperty(PROP_AFTERRUN); this.spAfterRunJumpTo = this.serializedObject.FindProperty(PROP_AFTERRUN_JUMPTO); this.SetupJumpOptions(); this.target.hideFlags = HideFlags.HideInInspector; }
public void OnDestroyItem() { if (this.spActionsOnClick.objectReferenceValue != null) { IActionsList list1 = (IActionsList)this.spActionsOnClick.objectReferenceValue; IActionsList list2 = (IActionsList)this.spActionsOnEquip.objectReferenceValue; IActionsList list3 = (IActionsList)this.spActionsOnUnequip.objectReferenceValue; IConditionsList cond1 = (IConditionsList)this.spConditionsEquip.objectReferenceValue; AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(list1.gameObject)); AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(list2.gameObject)); AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(list3.gameObject)); AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(cond1.gameObject)); AssetDatabase.SaveAssets(); } }
private void DuplicateMeleeClip() { string path = AssetDatabase.GetAssetPath(this.target); string newPath = AssetDatabase.GenerateUniqueAssetPath(path); MeleeClip newInstance = Instantiate(this.target) as MeleeClip; AssetDatabase.CreateAsset(newInstance, newPath); SerializedObject soNewInstance = new SerializedObject( AssetDatabase.LoadAssetAtPath <MeleeClip>(newPath) ); SerializedProperty newActionsOnHit = soNewInstance.FindProperty("actionsOnHit"); SerializedProperty newActionsOnExec = soNewInstance.FindProperty("actionsOnExecute"); IActionsList a1 = newActionsOnHit.objectReferenceValue as IActionsList; IActionsList a2 = newActionsOnExec.objectReferenceValue as IActionsList; GameObject a1Src = PrefabUtility.InstantiatePrefab(a1.gameObject) as GameObject; GameObject a2Src = PrefabUtility.InstantiatePrefab(a2.gameObject) as GameObject; PrefabUtility.UnpackPrefabInstance(a1Src, PrefabUnpackMode.OutermostRoot, InteractionMode.AutomatedAction); PrefabUtility.UnpackPrefabInstance(a2Src, PrefabUnpackMode.OutermostRoot, InteractionMode.AutomatedAction); string a1Path = AssetDatabase.GetAssetPath(a1.gameObject); string a2Path = AssetDatabase.GetAssetPath(a2.gameObject); string a1NewPath = AssetDatabase.GenerateUniqueAssetPath(a1Path); string a2NewPath = AssetDatabase.GenerateUniqueAssetPath(a2Path); GameObject p1Src = PrefabUtility.SaveAsPrefabAsset(a1Src, a1NewPath); GameObject p2Src = PrefabUtility.SaveAsPrefabAsset(a2Src, a2NewPath); newActionsOnHit.objectReferenceValue = p1Src.GetComponent <IActionsList>(); newActionsOnExec.objectReferenceValue = p2Src.GetComponent <IActionsList>(); soNewInstance.ApplyModifiedPropertiesWithoutUndo(); soNewInstance.Update(); DestroyImmediate(a1Src); DestroyImmediate(a2Src); }
public void OnDestroyStatusEffect() { SerializedProperty[] actions = new SerializedProperty[] { this.spActionsOnStart, this.spActionsWhileActive, this.spActionsOnEnd, }; for (int i = 0; i < actions.Length; ++i) { if (actions[i].objectReferenceValue == null) { continue; } IActionsList aList = (IActionsList)actions[i].objectReferenceValue; AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(aList.gameObject)); AssetDatabase.SaveAssets(); } }
// PRIVATE METHODS: ----------------------------------------------------------------------- private void ExecuteActions(IActionsList list, Action callback = null) { GameObject instance = Instantiate <GameObject>( list.gameObject, transform.position, transform.rotation ); Actions actions = instance.GetComponent <Actions>(); actions.destroyAfterFinishing = true; actions.onFinish.AddListener(() => { if (callback != null) { callback.Invoke(); } }); actions.Execute(gameObject); }