/// <summary> /// Copy constructor /// </summary> public AudioItem(AudioItem orig) { Name = orig.Name; Loop = orig.Loop; loopSequenceCount = orig.loopSequenceCount; loopSequenceOverlap = orig.loopSequenceOverlap; loopSequenceRandomDelay = orig.loopSequenceRandomDelay; loopSequenceRandomPitch = orig.loopSequenceRandomPitch; loopSequenceRandomVolume = orig.loopSequenceRandomVolume; DestroyOnLoad = orig.DestroyOnLoad; Volume = orig.Volume; SubItemPickMode = orig.SubItemPickMode; MinTimeBetweenPlayCalls = orig.MinTimeBetweenPlayCalls; MaxInstanceCount = orig.MaxInstanceCount; Delay = orig.Delay; PitchShift = orig.PitchShift; RandomVolume = orig.RandomVolume; RandomPitch = orig.RandomPitch; RandomDelay = orig.RandomDelay; overrideAudioSourceSettings = orig.overrideAudioSourceSettings; audioSource_MinDistance = orig.audioSource_MinDistance; audioSource_MaxDistance = orig.audioSource_MaxDistance; spatialBlend = orig.spatialBlend; for (int i = 0; i < orig.subItems.Length; ++i) { ArrayHelper.AddArrayElement(ref subItems, new AudioSubItem(orig.subItems[i], this)); } }
internal int _GetIndexOf(AudioItem audioItem) { if (AudioItems == null) { return(-1); } for (int i = 0; i < AudioItems.Length; i++) { if (audioItem == AudioItems[i]) { return(i); } } return(-1); }
/// <summary> /// Copy constructor /// </summary> public AudioSubItem(AudioSubItem orig, AudioItem item) { SubItemType = orig.SubItemType; if (SubItemType == AudioSubItemType.Clip) { Clip = orig.Clip; } else if (SubItemType == AudioSubItemType.Item) { ItemModeAudioID = orig.ItemModeAudioID; } Probability = orig.Probability; DisableOtherSubitems = orig.DisableOtherSubitems; Clip = orig.Clip; Volume = orig.Volume; PitchShift = orig.PitchShift; Pan2D = orig.Pan2D; Delay = orig.Delay; RandomPitch = orig.RandomPitch; RandomVolume = orig.RandomVolume; RandomDelay = orig.RandomDelay; ClipStopTime = orig.ClipStopTime; ClipStartTime = orig.ClipStartTime; FadeIn = orig.FadeIn; FadeOut = orig.FadeOut; RandomStartPosition = orig.RandomStartPosition; for (int i = 0; i < orig.individualSettings.Count; ++i) { individualSettings.Add(orig.individualSettings[i]); } this.item = item; }
void OnGUI() { if (!isInitialised) { Initialise(); } if (!_selectedAC) { _SetCurrentAudioController(_FindAudioController()); } if (_selectedAC == null && Selection.activeGameObject != null) { _SetCurrentAudioController(Selection.activeGameObject.GetComponent <AudioController>()); } if (_audioControllerNameList == null) { _FindAudioController(); if (_audioControllerNameList == null && _selectedAC != null) // can happen if AC was selected by Show( AC ) { _audioControllerNameList = new string[1] { _GetPrefabName(_selectedAC) }; } } if (!_selectedAC) { EditorGUILayout.LabelField("No AudioController found!"); return; } EditorGUILayout.BeginHorizontal(); int newACIndex = EditorGUILayout.Popup(_selectedACIndex, _audioControllerNameList, _headerStyleButton); if (newACIndex != _selectedACIndex) { _selectedACIndex = newACIndex; _SetCurrentAudioController(_audioControllerList[_selectedACIndex]); } if (GUILayout.Button("Select", GUILayout.MaxWidth(50))) { _SelectCurrentAudioController(); } if (_foldoutsSetFromController != _selectedAC) { _SetCategoryFoldouts(); } if (_searchString == null) { _searchString = ""; } _searchString = EditorGUILayout.TextField(" search item: ", _searchString); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Button(" ", _styleEmptyButton); EditorGUILayout.LabelField("Item", _headerStyle); EditorGUILayout.LabelField("Sub Item", _headerStyle); EditorGUILayout.EndHorizontal(); _scrollPos = EditorGUILayout.BeginScrollView(_scrollPos); if (_selectedAC != null && _selectedAC.AudioCategories != null) { if (_foldedOutCategories.Count == 0 && _selectedAC.AudioCategories.Length > 0) { // happens after Unity code recompile, we need to create _foldedOutCategories again _SetCategoryFoldouts(); } for (int categoryIndex = 0; categoryIndex < _selectedAC.AudioCategories.Length; categoryIndex++) { var category = _selectedAC.AudioCategories[categoryIndex]; if (string.IsNullOrEmpty(category.Name)) { Debug.LogWarning("empty category.Name"); continue; } if (!_foldedOutCategories.ContainsKey(category.Name)) { Debug.LogWarning("can not find category.Name: " + category.Name); // TODO: find out why this can happen sometimes continue; } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button((_foldedOutCategories[category.Name] ? "-\t" : "+\t") + category.Name, _styleCategoryButtonHeader)) { _foldedOutCategories[category.Name] = !_foldedOutCategories[category.Name]; } EditorGUILayout.EndHorizontal(); var filteredAudioItems = new List <AudioItem>(category.AudioItems); if (!string.IsNullOrEmpty(_searchString)) { bool catFoldedOut = false; for (int i = 0; i < filteredAudioItems.Count; ++i) { AudioItem item = filteredAudioItems[i]; if (!item.Name.ToLowerInvariant().Contains(_searchString.ToLowerInvariant())) { filteredAudioItems.RemoveAt(i--); } else { catFoldedOut = true; } } _foldedOutCategories[category.Name] = catFoldedOut && filteredAudioItems.Count > 0; } if (_foldedOutCategories[category.Name]) { if (category.AudioItems == null) { continue; } var sortedAudioItems = filteredAudioItems.OrderBy(x => x.Name).ToArray(); for (int itemIndex = 0; itemIndex < sortedAudioItems.Length; itemIndex++) { var item = sortedAudioItems[itemIndex]; string emptySpace = " "; EditorGUILayout.BeginHorizontal(); GUILayout.Button(emptySpace, _styleEmptyButton); GUILayout.Label(item.Name); if (GUILayout.Button(new GUIContent("Copy ID", "Copy audioID to clipboard"), _styleCopyIDButton, GUILayout.MaxWidth(50))) { EditorGUIUtility.systemCopyBuffer = item.Name; } EditorGUILayout.EndHorizontal(); if (item.subItems == null) { continue; } for (int subitemIndex = 0; subitemIndex < item.subItems.Length; subitemIndex++) { var subItem = item.subItems[subitemIndex]; GUILayout.BeginHorizontal(); GUILayout.Button(emptySpace, _styleEmptyButton); EditorGUILayout.BeginHorizontal(); string listItemDisplay = ""; string listItemTypeDisplay = " "; if (subItem.SubItemType == AudioSubItemType.Clip) { if (subItem.Clip != null) { listItemDisplay = subItem.Clip.name; listItemTypeDisplay += "CLIP:"; } else { listItemDisplay = "*unset*"; listItemTypeDisplay += "CLIP:"; } } else { listItemTypeDisplay += "ITEM:"; listItemDisplay = subItem.ItemModeAudioID; } EditorGUILayout.LabelField(listItemTypeDisplay, GUILayout.MaxWidth(_buttonSize)); if (GUILayout.Button(listItemDisplay, subitemIndex % 2 == 0 ? _styleListItemButton0 : _styleListItemButton1, GUILayout.ExpandWidth(true))) { _selectedAC._currentInspectorSelection.currentCategoryIndex = categoryIndex; _selectedAC._currentInspectorSelection.currentItemIndex = Array.FindIndex(category.AudioItems, x => x.Name == item.Name); _selectedAC._currentInspectorSelection.currentSubitemIndex = subitemIndex; _SelectCurrentAudioController(); } if (subItem.SubItemType == AudioSubItemType.Clip) { if (subItem.Clip != null) { if (GUILayout.Button("Clip", subitemIndex % 2 == 0 ? _styleListItemButton0 : _styleListItemButton1, GUILayout.MaxWidth(50))) { Selection.activeObject = subItem.Clip; EditorGUIUtility.PingObject(subItem.Clip); } } } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndHorizontal(); } } } } } EditorGUILayout.EndScrollView(); }