// INITIALIZE: ---------------------------------------------------------------------------- private void OnEnable() { if (target == null || serializedObject == null) { return; } this.spStatsAsset = serializedObject.FindProperty("statsAsset"); this.spAttributesAsset = serializedObject.FindProperty("attrsAsset"); this.spStatusEffectsAsset = serializedObject.FindProperty("statusEffectsAsset"); if (this.spStatsAsset.objectReferenceValue == null) { string path = Path.Combine(ASSETS_PATH, STATSASSET_FILE); StatsAsset statsAsset = AssetDatabase.LoadAssetAtPath <StatsAsset>(path); if (statsAsset == null) { statsAsset = CreateStatsAsset(); } this.spStatsAsset.objectReferenceValue = statsAsset; serializedObject.ApplyModifiedPropertiesWithoutUndo(); serializedObject.Update(); } if (this.spAttributesAsset.objectReferenceValue == null) { string path = Path.Combine(ASSETS_PATH, ATTRSASSET_FILE); AttrsAsset attributesAsset = AssetDatabase.LoadAssetAtPath <AttrsAsset>(path); if (attributesAsset == null) { attributesAsset = CreateAttributesAsset(); } this.spAttributesAsset.objectReferenceValue = attributesAsset; serializedObject.ApplyModifiedPropertiesWithoutUndo(); serializedObject.Update(); } if (this.spStatusEffectsAsset.objectReferenceValue == null) { string path = Path.Combine(ASSETS_PATH, STAEFASSET_FILE); StatusEffectsAsset statusEffectsAsset = AssetDatabase.LoadAssetAtPath <StatusEffectsAsset>(path); if (statusEffectsAsset == null) { statusEffectsAsset = CreateStatusEffectsAsset(); } this.spStatusEffectsAsset.objectReferenceValue = statusEffectsAsset; serializedObject.ApplyModifiedPropertiesWithoutUndo(); serializedObject.Update(); } this.statsAssetEditor = (StatsAssetEditor)CreateEditor(this.spStatsAsset.objectReferenceValue); this.attrsAssetEditor = (AttrsAssetEditor)CreateEditor(this.spAttributesAsset.objectReferenceValue); this.statusEffectsAssetEditor = (StatusEffectsAssetEditor)CreateEditor(this.spStatusEffectsAsset.objectReferenceValue); }
public static StatusEffectsAsset GetStatusEffectsAsset() { string path = Path.Combine(ASSETS_PATH, STAEFASSET_FILE); StatusEffectsAsset statusEffectsAsset = AssetDatabase.LoadAssetAtPath <StatusEffectsAsset>(path); if (statusEffectsAsset == null) { statusEffectsAsset = CreateStatusEffectsAsset(); } return(statusEffectsAsset); }
// INITIALIZERS: -------------------------------------------------------------------------- private void OnEnable() { if (target == null || serializedObject == null) { return; } this.instance = (StatusEffectsAsset)target; this.spStatusEffects = serializedObject.FindProperty("statusEffects"); this.editorSortableList = new EditorSortableList(); this.UpdateSubEditors(this.instance.statusEffects); }
public static StatusEffectsAsset CreateStatusEffectsAsset() { string filepath = ASSETS_PATH; string filename = STAEFASSET_FILE; StatusEffectsAsset asset = ScriptableObject.CreateInstance <StatusEffectsAsset>(); GameCreatorUtilities.CreateFolderStructure(filepath); string path = Path.Combine(filepath, filename); path = AssetDatabase.GenerateUniqueAssetPath(path); AssetDatabase.CreateAsset(asset, path); AssetDatabase.ImportAsset(path); return(asset); }