private void UpdateInitActions() { if (!this.spUseActionsList.boolValue) { return; } if (this.spPrefabActionsList.objectReferenceValue == null) { string actionsName = Guid.NewGuid().ToString("N"); GameCreatorUtilities.CreateFolderStructure(PATH_ACTIONS); string path = Path.Combine(PATH_ACTIONS, string.Format(PREFAB_NAME, actionsName)); path = AssetDatabase.GenerateUniqueAssetPath(path); GameObject sceneInstance = new GameObject(actionsName); sceneInstance.AddComponent <Actions>(); GameObject prefabInstance = PrefabUtility.SaveAsPrefabAsset(sceneInstance, path); DestroyImmediate(sceneInstance); Actions prefabActions = prefabInstance.GetComponent <Actions>(); prefabActions.destroyAfterFinishing = true; this.spPrefabActionsList.objectReferenceValue = prefabActions.actionsList; this.serializedObject.ApplyModifiedPropertiesWithoutUndo(); this.serializedObject.Update(); } if (this.editorActionsList == null) { this.editorActionsList = Editor.CreateEditor( this.spPrefabActionsList.objectReferenceValue ) as IActionsListEditor; } }
private void SetupActionsList(ref SerializedProperty sp, ref IActionsListEditor editor, string prefabPath, string prefabName) { if (sp.objectReferenceValue == null) { GameCreatorUtilities.CreateFolderStructure(prefabPath); string actionsPath = AssetDatabase.GenerateUniqueAssetPath(Path.Combine( prefabPath, prefabName )); GameObject sceneInstance = new GameObject("Actions"); sceneInstance.AddComponent <Actions>(); GameObject prefabInstance = PrefabUtility.SaveAsPrefabAsset(sceneInstance, actionsPath); DestroyImmediate(sceneInstance); Actions prefabActions = prefabInstance.GetComponent <Actions>(); prefabActions.destroyAfterFinishing = true; sp.objectReferenceValue = prefabActions.actionsList; serializedObject.ApplyModifiedPropertiesWithoutUndo(); serializedObject.Update(); } editor = Editor.CreateEditor( sp.objectReferenceValue, typeof(IActionsListEditor) ) as IActionsListEditor; }
private void PaintStartActions() { this.sectionStartActions.PaintSection(); using (var group = new EditorGUILayout.FadeGroupScope(this.sectionStartActions.state.faded)) { if (group.visible) { EditorGUILayout.BeginVertical(CoreGUIStyles.GetBoxExpanded()); if (this.editorStartActions == null) { if (this.trigger.onStartActions == null) { SerializedProperty spOnComplete = this.serializedObject.FindProperty("onStartActions"); spOnComplete.objectReferenceValue = this.trigger.gameObject.AddComponent <IActionsList>(); serializedObject.ApplyModifiedProperties(); serializedObject.Update(); } this.editorStartActions = (IActionsListEditor)Editor.CreateEditor(this.trigger.onStartActions); } //EditorGUILayout.HelpBox(MSG_ACTIONS, MessageType.Info); this.editorStartActions.OnInspectorGUI(); EditorGUILayout.EndVertical(); } } }
private void PaintActionsOnExecute() { if (this.actionsOnExecute == null) { this.actionsOnExecute = Editor.CreateEditor( this.spActionsOnExecute.objectReferenceValue ) as IActionsListEditor; } this.actionsOnExecute.OnInspectorGUI(); }
protected void PaintActionsTab() { EditorGUILayout.PropertyField(this.spExecuteBehavior); if (this.actionsListEditor == null) { this.actionsListEditor = (IActionsListEditor)IActionsListEditor.CreateEditor( this.spActionsList.objectReferenceValue, typeof(IActionsListEditor) ); } if (this.actionsListEditor != null) { this.actionsListEditor.OnInspectorGUI(); } }
public void PaintOnFail() { if (this.editorOnFail == null) { if (this.reaction.onFail == null) { SerializedProperty spOnFail = this.serializedObject.FindProperty("onFail"); spOnFail.objectReferenceValue = this.reaction.gameObject.AddComponent <IActionsList>(); serializedObject.ApplyModifiedProperties(); serializedObject.Update(); } this.editorOnFail = (IActionsListEditor)Editor.CreateEditor(this.reaction.onFail); } EditorGUILayout.HelpBox(MSG_ONFAIL, MessageType.Info); this.editorOnFail.OnInspectorGUI(); }
private void PaintEveryoneActions() { if (this.editorEveryoneActions == null) { if (this.trigger.onPickUpEveryone == null) { SerializedProperty spOnComplete = this.serializedObject.FindProperty("onPickUpEveryone"); spOnComplete.objectReferenceValue = this.trigger.gameObject.AddComponent <IActionsList>(); serializedObject.ApplyModifiedProperties(); serializedObject.Update(); } this.editorEveryoneActions = (IActionsListEditor)Editor.CreateEditor(this.trigger.onPickUpEveryone); } EditorGUILayout.HelpBox(MSG_ACTIONS_EVERY, MessageType.Info); this.editorEveryoneActions.OnInspectorGUI(); }
public void PaintOnComplete() { if (this.editorOnComplete == null) { if (this.reaction.onComplete == null) { SerializedProperty spOnComplete = this.serializedObject.FindProperty("onComplete"); spOnComplete.objectReferenceValue = this.reaction.gameObject.AddComponent <IActionsList>(); serializedObject.ApplyModifiedPropertiesWithoutUndo(); serializedObject.Update(); } this.editorOnComplete = (IActionsListEditor)Editor.CreateEditor(this.reaction.onComplete); } EditorGUILayout.HelpBox(MSG_ONCOMP, MessageType.Info); this.editorOnComplete.OnInspectorGUI(); }
// METHODS: ---------------------------------------------------------------------------------------------------- private void OnEnable() { this.spUUID = serializedObject.FindProperty(PROP_UUID); this.spName = serializedObject.FindProperty(PROP_NAME); this.spDescription = serializedObject.FindProperty(PROP_DESCRIPTION); this.spSprite = serializedObject.FindProperty(PROP_SPRITE); this.spPrefab = serializedObject.FindProperty(PROP_PREFAB); this.spPrice = serializedObject.FindProperty(PROP_PRICE); this.spMaxStack = serializedObject.FindProperty(PROP_MAXSTACK); this.spConsumable = serializedObject.FindProperty(PROP_CONSUMABLE); this.spActionsList = serializedObject.FindProperty(PROP_ACTIONSLIST); if (this.spActionsList.objectReferenceValue == null) { GameCreatorUtilities.CreateFolderStructure(PATH_PREFAB_CONSUME); string actionsPath = AssetDatabase.GenerateUniqueAssetPath(Path.Combine( PATH_PREFAB_CONSUME, NAME_PREFAB_CONSUME) ); GameObject sceneInstance = new GameObject("ConsumeActions"); sceneInstance.AddComponent <Actions>(); GameObject prefabInstance = PrefabUtility.CreatePrefab(actionsPath, sceneInstance); DestroyImmediate(sceneInstance); Actions prefabActions = prefabInstance.GetComponent <Actions>(); prefabActions.destroyAfterFinishing = true; this.spActionsList.objectReferenceValue = prefabActions.actionsList; serializedObject.ApplyModifiedProperties(); serializedObject.Update(); } this.actionsListEditor = (IActionsListEditor)IActionsListEditor.CreateEditor( this.spActionsList.objectReferenceValue, typeof(IActionsListEditor) ); this.animUnfold = new AnimBool(false); this.animUnfold.speed = ANIM_BOOL_SPEED; this.animUnfold.valueChanged.AddListener(this.Repaint); }
// METHODS: ---------------------------------------------------------------------------------------------------- private void OnEnable() { this.spItemHolderToCombineA = serializedObject.FindProperty(PROP_ITEM_1); this.spItemToCombineA = this.spItemHolderToCombineA.FindPropertyRelative("item"); this.spAmountA = serializedObject.FindProperty(PROP_AMOU_1); this.spItemHolderToCombineB = serializedObject.FindProperty(PROP_ITEM_2); this.spItemToCombineB = this.spItemHolderToCombineB.FindPropertyRelative("item"); this.spAmountB = serializedObject.FindProperty(PROP_AMOU_2); this.spRemoveItemsOnCraft = serializedObject.FindProperty(PROP_ONCRAFT); this.spActionsList = serializedObject.FindProperty(PROP_ACTION); if (this.spActionsList.objectReferenceValue == null) { GameCreatorUtilities.CreateFolderStructure(PATH_PREFAB_RECIPES); string actionsPath = AssetDatabase.GenerateUniqueAssetPath(Path.Combine( PATH_PREFAB_RECIPES, NAME_PREFAB_RECIPES) ); GameObject sceneInstance = new GameObject("RecipeActions"); sceneInstance.AddComponent <Actions>(); GameObject prefabInstance = PrefabUtility.CreatePrefab(actionsPath, sceneInstance); DestroyImmediate(sceneInstance); Actions prefabActions = prefabInstance.GetComponent <Actions>(); prefabActions.destroyAfterFinishing = true; this.spActionsList.objectReferenceValue = prefabActions.actionsList; serializedObject.ApplyModifiedProperties(); serializedObject.Update(); } this.actionsListEditor = (IActionsListEditor)IActionsListEditor.CreateEditor( this.spActionsList.objectReferenceValue, typeof(IActionsListEditor) ); this.animUnfold = new AnimBool(false); this.animUnfold.speed = ANIM_BOOL_SPEED; this.animUnfold.valueChanged.AddListener(this.Repaint); }
private void PaintActions() { if (this.actionsOnStartCharge == null) { this.actionsOnStartCharge = Editor.CreateEditor( this.spActionsOnStartCharge.objectReferenceValue ) as IActionsListEditor; } if (this.actionsOnEndCharge == null) { this.actionsOnEndCharge = Editor.CreateEditor( this.spActionsOnEndCharge.objectReferenceValue ) as IActionsListEditor; } if (this.actionsOnShoot == null) { this.actionsOnShoot = Editor.CreateEditor( this.spActionsOnShoot.objectReferenceValue ) as IActionsListEditor; } EditorGUILayout.Space(); EditorGUILayout.Space(); this.toolbarIndex = GUILayout.Toolbar(this.toolbarIndex, OPTIONS_ACTIONS); GUILayout.Space(SPACING); switch (this.toolbarIndex) { case 0: this.actionsOnStartCharge.OnInspectorGUI(); break; case 1: this.actionsOnShoot.OnInspectorGUI(); break; case 2: this.actionsOnEndCharge.OnInspectorGUI(); break; } }
// INITIALIZERS: -------------------------------------------------------------------------- private void OnEnable() { if (target == null || serializedObject == null) { return; } this.spUniqueID = serializedObject.FindProperty(PROP_UNIQUE_ID); this.spStatusEffect = serializedObject.FindProperty("statusEffect"); if (string.IsNullOrEmpty(this.spUniqueID.stringValue)) { this.spUniqueID.stringValue = Guid.NewGuid().ToString("N"); serializedObject.ApplyModifiedPropertiesWithoutUndo(); serializedObject.Update(); } this.spActionsOnStart = spStatusEffect.FindPropertyRelative(PROP_ACTIONS_ONSTART); this.spActionsWhileActive = spStatusEffect.FindPropertyRelative(PROP_ACTIONS_WHILEACTIVE); this.spActionsOnEnd = spStatusEffect.FindPropertyRelative(PROP_ACTIONS_ONEND); this.RequireActionsInit(ref this.spActionsOnStart, NAME_PREFAB_ONSTART, true); this.RequireActionsInit(ref this.spActionsWhileActive, NAME_PREFAB_WHILEACTIVE, false); this.RequireActionsInit(ref this.spActionsOnEnd, NAME_PREFAB_ONEND, true); this.editorActionsOnStart = (IActionsListEditor)Editor.CreateEditor( this.spActionsOnStart.objectReferenceValue, typeof(IActionsListEditor) ); this.editorActionsWhileActive = (IActionsListEditor)Editor.CreateEditor( this.spActionsWhileActive.objectReferenceValue, typeof(IActionsListEditor) ); this.editorActionsOnEnd = (IActionsListEditor)Editor.CreateEditor( this.spActionsOnEnd.objectReferenceValue, typeof(IActionsListEditor) ); }