private void OnAddQuestContentType(object data) { var isSelectedQuest = m_isAsset; if (isSelectedQuest) { QuestEditorWindow.ApplyModifiedPropertiesFromSelectedQuestSerializedObject(); } var type = data as Type; var content = ScriptableObjectUtility.CreateScriptableObject(type); content.name = type.Name; m_selectedQuestContent = content as QuestContent; m_contentEditor = null; if (isSelectedQuest) { AssetUtility.AddToAsset(content, QuestEditorWindow.selectedQuestSerializedObject.targetObject); QuestEditorWindow.UpdateSelectedQuestSerializedObject(); } m_list.serializedProperty.arraySize++; m_list.index = m_list.serializedProperty.arraySize - 1; m_list.serializedProperty.GetArrayElementAtIndex(m_list.serializedProperty.arraySize - 1).objectReferenceValue = content; m_list.serializedProperty.serializedObject.ApplyModifiedProperties(); m_serializedObject.ApplyModifiedProperties(); if (isSelectedQuest) { QuestEditorWindow.ApplyModifiedPropertiesFromSelectedQuestSerializedObject(); AssetDatabase.SaveAssets(); } m_needToClearFocus = true; }
protected void AddAndSaveSubasset(QuestSubasset subasset) { if (QuestEditorWindow.selectedQuest != null) { AssetUtility.AddToAsset(subasset, QuestEditorWindow.selectedQuest); subasset.SetRuntimeReferences(QuestEditorWindow.selectedQuest, null); } QuestEditorWindow.UpdateSelectedQuestSerializedObject(); QuestEditorWindow.ApplyModifiedPropertiesFromSelectedQuestSerializedObject(); AssetDatabase.SaveAssets(); }
private void OnRemoveElement(ReorderableList list) { var isIndexValid = (0 <= list.index && list.index < list.count); if (!isIndexValid) { return; } QuestEditorWindow.ApplyModifiedPropertiesFromSelectedQuestSerializedObject(); var condition = list.serializedProperty.GetArrayElementAtIndex(list.index).objectReferenceValue as QuestCondition; QuestEditorUtility.RemoveReorderableListElementWithoutLeavingNull(list); QuestEditorWindow.ApplyModifiedPropertiesFromSelectedQuestSerializedObject(); AssetUtility.DeleteFromAsset(condition, QuestEditorWindow.selectedQuest); OnSelectElement(list); }
private void OnAddQuestActionType(object data) { QuestEditorWindow.ApplyModifiedPropertiesFromSelectedQuestSerializedObject(); var type = data as Type; var questAction = ScriptableObjectUtility.CreateScriptableObject(type); questAction.name = type.Name; m_selectedAction = questAction as QuestAction; m_actionEditor = null; if (QuestEditorWindow.selectedQuest != null) { AssetUtility.AddToAsset(questAction, QuestEditorWindow.selectedQuest); m_selectedAction.SetRuntimeReferences(QuestEditorWindow.selectedQuest, null); } QuestEditorWindow.UpdateSelectedQuestSerializedObject(); m_list.serializedProperty.arraySize++; m_list.index = m_list.serializedProperty.arraySize - 1; m_list.serializedProperty.GetArrayElementAtIndex(m_list.serializedProperty.arraySize - 1).objectReferenceValue = questAction; m_list.serializedProperty.serializedObject.ApplyModifiedProperties(); QuestEditorWindow.ApplyModifiedPropertiesFromSelectedQuestSerializedObject(); AssetDatabase.SaveAssets(); }