void ShowFolderButton(GameObject gameObject, Rect selectionrect) { #if UNITY_EDITOR Texture folderIcon = UnityEditor.EditorGUIUtility.IconContent("Project").image; float width = selectionrect.width; selectionrect.width = 30; selectionrect.height = 16; selectionrect.x = width - 2 + gameObject.GetHierarchyDepth() * 14; selectionrect.height += 1; GUIStyle style = new GUIStyle("MiniToolbarButtonLeft"); style.fixedHeight += 1; style.contentOffset = new Vector2(-4, 0); style.clipping = TextClipping.Overflow; if (GUI.Button(selectionrect, folderIcon, style)) { List<Object> selectedGameObjects = new List<Object>(UnityEditor.Selection.objects); if (selection.Contains(gameObject)) { selectedGameObjects.Remove(gameObject); } selectedGameObjects.AddRange(gameObject.GetChildrenRecursive()); foreach (GameObject folder in pureData.hierarchyManager.folderStructure) { if (selectedGameObjects.Contains(folder)) { selectedGameObjects.Remove(folder); } } UnityEditor.Selection.objects = selectedGameObjects.ToArray(); } #endif }
void ShowPreviewButton(PureDataSetup setup, GameObject gameObject, Rect selectionrect) { #if UNITY_EDITOR Texture previewIcon = UnityEditor.EditorGUIUtility.ObjectContent(null, typeof(AudioSource)).image; PureDataInfo info = setup.Info; float width = selectionrect.width; selectionrect.width = 30; selectionrect.height = 16; selectionrect.x = width - 2 + gameObject.GetHierarchyDepth() * 14; selectionrect.height += 1; GUIStyle style = new GUIStyle("MiniToolbarButtonLeft"); style.fixedHeight += 1; style.contentOffset = new Vector2(-4, 0); style.clipping = TextClipping.Overflow; if (GUI.Button(selectionrect, previewIcon, style)) { UnityEditor.Selection.activeObject = gameObject; if (previewAudioSource != null) { previewAudioSource.gameObject.Remove(); } previewAudioSource = setup.Clip.PlayOnListener(); if (previewAudioSource != null) { previewAudioSource.volume = info.volume + info.volume * Random.Range(-info.randomVolume, info.randomVolume); previewAudioSource.pitch = info.pitch + info.pitch * Random.Range(-info.randomPitch, info.randomPitch); previewAudioSource.time = previewAudioSource.pitch >= 0 ? previewAudioSource.clip.length * info.playRangeStart : previewAudioSource.clip.length * Mathf.Min(info.playRangeEnd, 0.99999F); previewStopTime = previewAudioSource.pitch >= 0 ? previewAudioSource.clip.length * info.playRangeEnd : previewAudioSource.clip.length * info.playRangeStart; routine = DestroyAfterPlaying(previewAudioSource); } } else if (Event.current.isMouse && Event.current.type == EventType.mouseDown) { if (previewAudioSource != null) { previewAudioSource.gameObject.Remove(); } routine = null; } #endif }
void ShowPureDataIcon(GameObject gameObject, Rect selectionrect) { pureDataIcon = pureDataIcon ?? HelperFunctions.LoadAssetInFolder<Texture>("pd.png", "Magicolo/AudioTools/PureData"); float width = selectionrect.width; selectionrect.width = 16; selectionrect.height = 16; if (pureDataIcon != null) { selectionrect.x = width - 4 + gameObject.GetHierarchyDepth() * 14; GUI.DrawTexture(selectionrect, pureDataIcon); } }