private void SetupConditionsList(ref SerializedProperty sp, ref IConditionsListEditor editor, string prefabPath, string prefabName) { if (sp.objectReferenceValue == null) { GameCreatorUtilities.CreateFolderStructure(prefabPath); string conditionsPath = AssetDatabase.GenerateUniqueAssetPath(Path.Combine( prefabPath, prefabName )); GameObject sceneInstance = new GameObject("Conditions"); sceneInstance.AddComponent <IConditionsList>(); GameObject prefabInstance = PrefabUtility.SaveAsPrefabAsset(sceneInstance, conditionsPath); DestroyImmediate(sceneInstance); sp.objectReferenceValue = prefabInstance.GetComponent <IConditionsList>(); serializedObject.ApplyModifiedPropertiesWithoutUndo(); serializedObject.Update(); } editor = Editor.CreateEditor( sp.objectReferenceValue, typeof(IConditionsListEditor) ) as IConditionsListEditor; }
private void UpdateInitConditions() { if (!this.spUseConditionsList.boolValue) { return; } if (this.spPrefabConditionsList.objectReferenceValue == null) { string conditionsName = Guid.NewGuid().ToString("N"); GameCreatorUtilities.CreateFolderStructure(PATH_CONDITIONS); string path = Path.Combine(PATH_CONDITIONS, string.Format(PREFAB_NAME, conditionsName)); path = AssetDatabase.GenerateUniqueAssetPath(path); GameObject sceneInstance = new GameObject(conditionsName); sceneInstance.AddComponent <IConditionsList>(); GameObject prefabInstance = PrefabUtility.SaveAsPrefabAsset(sceneInstance, path); DestroyImmediate(sceneInstance); IConditionsList prefabConditions = prefabInstance.GetComponent <IConditionsList>(); this.spPrefabConditionsList.objectReferenceValue = prefabConditions; this.serializedObject.ApplyModifiedPropertiesWithoutUndo(); this.serializedObject.Update(); } if (this.editorConditionsList == null) { this.editorConditionsList = Editor.CreateEditor( this.spPrefabConditionsList.objectReferenceValue ) as IConditionsListEditor; } }
protected void PaintConditionsTab() { if (this.conditionListEditor == null) { this.conditionListEditor = (IConditionsListEditor)IConditionsListEditor.CreateEditor( this.spConditionList.objectReferenceValue, typeof(IConditionsListEditor) ); } if (this.conditionListEditor != null) { this.conditionListEditor.OnInspectorGUI(); } }
public void PaintConditions() { if (this.editorConditions == null) { if (this.reaction.conditions == null) { SerializedProperty spConditions = this.serializedObject.FindProperty("conditions"); spConditions.objectReferenceValue = this.reaction.gameObject.AddComponent <IConditionsList>(); serializedObject.ApplyModifiedProperties(); serializedObject.Update(); } this.editorConditions = (IConditionsListEditor)Editor.CreateEditor(this.reaction.conditions); } EditorGUILayout.HelpBox(MSG_CONDIT, MessageType.Info); this.editorConditions.OnInspectorGUI(); }