private void OnEnable() { manager = AssetDatabase.LoadAssetAtPath <QuestManagerAsset>(AssetPath); QuestAsset[] quests = manager.GetQuests(); questIndices = new int[quests.Length]; for (int i = 0; i < questIndices.Length; i++) { questIndices[i] = i; } dependenciesProperty = serializedObject.FindProperty("dependencies"); }
public void OnQuestRemoveElement(ReorderableList reorderableList) { Undo.RecordObject(serializedObject.targetObject, "Delete Quest Item"); if (questEditor != null) { DestroyImmediate(questEditor); } QuestManagerAsset st = ((QuestManagerAsset)serializedObject.targetObject); QuestAsset p = st.GetQuests()[reorderableList.index]; ProgressionPointAsset[] progressionPoints = p.GetProgressionPoints(); for (int i = 0; i < progressionPoints.Length; i++) { DestroyAsset(progressionPoints[i]); } reorderableList.serializedProperty.DeleteArrayElementAtIndex(reorderableList.index); reorderableList.serializedProperty.MoveArrayElement(reorderableList.index, reorderableList.count - 1); reorderableList.serializedProperty.arraySize--; if (p != null) { DestroyAsset(p); } }
public void OnDisable() { if (questEditor != null) { DestroyImmediate(questEditor); } Object main = AssetDatabase.LoadMainAssetAtPath(AssetPath); QuestManagerAsset questManager = (QuestManagerAsset)main; if (questManager == null) { return; } QuestAsset[] quests = questManager.GetQuests(); for (int i = 0; i < quests.Length; i++) { if (AssetPath != AssetDatabase.GetAssetPath(quests[i])) { AssetDatabase.AddObjectToAsset(quests[i], questManager); } } ProgressionPointAsset[] progressionPoints = questManager.GetProgressionPoints(); for (int i = 0; i < progressionPoints.Length; i++) { if (AssetPath != AssetDatabase.GetAssetPath(progressionPoints[i])) { AssetDatabase.AddObjectToAsset(progressionPoints[i], questManager); } } if (AssetPath != null && AssetPath != "") { EditorApplication.delayCall += () => { AssetDatabase.ImportAsset(AssetPath); } } ; }