void AddQuest() { QuestSO asset = ScriptableObject.CreateInstance <QuestSO>(); int questlineId = 0; questlineId = selectedQuestLine.IdQuestline; int questId = 0; questId = selectedQuestLine.Quests.Count + 1; AssetDatabase.CreateFolder("Assets/ScriptableObjects/Quests/Questline" + questlineId, "Quest" + questId); AssetDatabase.CreateAsset(asset, "Assets/ScriptableObjects/Quests/Questline" + questlineId + "/Quest" + questId + "/Q" + questId + "-QL" + questlineId + ".asset"); AssetDatabase.SaveAssets(); asset.SetQuestId(questId); selectedQuestLine.Quests.Add(asset); //refresh rootVisualElement.Q <VisualElement>("questlines-list").Q <ListView>().SetSelection(idQuestlineSelected); }
void AddQuest() { QuestSO asset = CreateInstance <QuestSO>(); int questlineId = 0; questlineId = _currentSelectedQuestLine.IdQuestline; int questId = 0; questId = _currentSelectedQuestLine.Quests.Count + 1; if (!AssetDatabase.IsValidFolder("Assets/ScriptableObjects/Quests/Questline" + questlineId + "/Quest" + questId)) { AssetDatabase.CreateFolder("Assets/ScriptableObjects/Quests/Questline" + questlineId, "Quest" + questId); } AssetDatabase.CreateAsset(asset, "Assets/ScriptableObjects/Quests/Questline" + questlineId + "/Quest" + questId + "/Q" + questId + "-QL" + questlineId + ".asset"); asset.SetQuestId(questId); _currentSelectedQuestLine.Quests.Add(asset); EditorUtility.SetDirty(asset); EditorUtility.SetDirty(_currentSelectedQuestLine); AssetDatabase.SaveAssets(); //refresh rootVisualElement.Q <VisualElement>("questlines-list").Q <ListView>().SetSelection(_idQuestlineSelected); }