private void DrawMain() { if (_ac._database == null) { return; } EditorGUILayout.BeginHorizontal(EditorStyles.helpBox); if (GUILayout.Button("DELETE DATA")) { AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(_ac._database)); return; } var db = _ac._database; if (GUILayout.Button("ADD CATEGORY")) { var category = new Model.CategoryItem(); var categories = new Model.CategoryItem[db.items != null ? db.items.Length + 1 : 1]; if (db.items != null) { db.items.CopyTo(categories, 0); } categories[categories.Length - 1] = category; db.items = categories; } EditorGUILayout.EndHorizontal(); DrawCategories(_ac._database); }
private void DrawCategory(Model.CategoryItem item, int index) { EditorGUILayout.BeginVertical(EditorStyles.helpBox); item.name = EditorGUILayout.TextField("Name", item.name); item.audioObjectPrefab = (GameObject)EditorGUILayout.ObjectField("Category AO prefab", item.audioObjectPrefab, typeof(GameObject), false); item.usingDefaultPrefab = item.audioObjectPrefab == null; item.isMute = EditorGUILayout.Toggle("Is Mute", item.isMute); item.categoryVolume = EditorGUILayout.Slider("Category Volume", item.categoryVolume, 0f, 1f); EditorGUILayout.BeginHorizontal(EditorStyles.helpBox); if (GUILayout.Button("ADD SOUND ITEM")) { var soundItem = new Model.SoundItem(); bool isNoSoundItems = item.soundItems == null; var soundItems = new Model.SoundItem[!isNoSoundItems ? item.soundItems.Length + 1 : 1]; if (!isNoSoundItems) { item.soundItems.CopyTo(soundItems, 0); } soundItems[soundItems.Length - 1] = soundItem; item.soundItems = soundItems; } string nameAbv = ""; if (string.IsNullOrEmpty(item.name) == false) { nameAbv = item.name.Length > NAME_ABV_LEN?item.name.Substring(0, NAME_ABV_LEN) : item.name; } if (GUILayout.Button("Delete " + nameAbv)) { DeleteCategory(index); } EditorGUILayout.EndHorizontal(); if (item.soundItems != null) { if (item.soundItems.Length != 0) { item.soundsSearchName = EditorGUILayout.TextField("Search sound item", item.soundsSearchName); } } item.foldOutSoundItems = DrawSoundItems(item, item.foldOutSoundItems, item.soundsSearchName); EditorGUILayout.EndVertical(); }
private void DeleteCategory(int index) { var categories = new Model.CategoryItem[_ac._database.items.Length - 1]; int catInd = 0; for (int i = 0; i < _ac._database.items.Length; i++) { if (i == index) { continue; } categories[catInd] = _ac._database.items[i]; catInd += 1; } _ac._database.items = categories; }
private bool DrawSoundItems(Model.CategoryItem item, bool foldOut, string searchName) { Model.SoundItem[] items = item.soundItems; if (items == null || items.Length == 0) { return(foldOut); } EditorGUI.indentLevel++; EditorGUILayout.BeginHorizontal(); foldOut = EditorGUILayout.Foldout(foldOut, "SOUND ITEMS", true); if (items != null) { if (items.Length != 0) { if (GUILayout.Button("DELETE ALL SOUNDS")) { items = new Model.SoundItem[0]; item.soundItems = items; return(foldOut); } } } EditorGUILayout.EndHorizontal(); if (foldOut) { for (int j = items.Length - 1; j >= 0; j--) { if (!string.IsNullOrEmpty(items[j].name)) { if (items[j].name.ToLower().Contains(searchName.ToLower()) == false && string.IsNullOrEmpty(searchName) == false) { continue; } } DrawSoundItem(items[j], j, items); } } EditorGUI.indentLevel--; return(foldOut); }