public override void OnHierarchyWindowItemGUI(int instanceId, Rect selectionrect) { base.OnHierarchyWindowItemGUI(instanceId, selectionrect); #if UNITY_EDITOR GameObject gameObject = UnityEditor.EditorUtility.InstanceIDToObject(instanceId) as GameObject; if (gameObject == null || pureData == null) { return; } if (gameObject == pureData.gameObject) { ShowPureDataIcon(gameObject, selectionrect); } else if (pureData.hierarchyManager.folderStructure.Contains(gameObject)) { ShowFolderButton(gameObject, selectionrect); } else { PureDataSetup setup = gameObject.GetComponent <PureDataSetup>(); if (setup != null && setup.Info != null) { ShowPreviewButton(setup, gameObject, selectionrect); } } #endif }
public void CreateHierarchy() { #if UNITY_EDITOR foreach (AudioClip clip in clips) { string clipPath = UnityEditor.AssetDatabase.GetAssetPath(clip).GetRange("Assets/Resources/".Length); string clipDirectory = Path.GetDirectoryName(clipPath); GameObject parent = GetOrAddFolder(clipDirectory); GameObject child = GameObject.Find(clip.name); if (child == null) { child = new GameObject(clip.name); PureDataSetup setup = child.GetOrAddComponent <PureDataSetup>(); setup.name = clip.name; setup.Info = pureData.infoManager.GetInfo(clip.name); setup.pureData = pureData; setup.FreezeTransform(); } child.transform.parent = parent.transform; child.transform.Reset(); } #endif }
public override void OnInspectorGUI() { Begin(); EditorGUI.BeginChangeCheck(); ShowGeneralSettings(); ShowSpatialSetting(); ShowClipSettings(); if (EditorGUI.EndChangeCheck()) { foreach (GameObject gameObject in Selection.gameObjects) { PureDataSetup selectedSetup = gameObject.GetComponent <PureDataSetup>(); if (selectedSetup != null) { selectedSetup.UpdateInfo(); } } } End(); }
public override void OnEnable() { base.OnEnable(); setup = (PureDataSetup)target; info = setup.Info; infoProperty = serializedObject.FindProperty("info"); clip = setup.Clip; }
void ShowWaveCurves() { if (curveLeft == null || curveRight == null) { float[] dataLeft; float[] dataRight; clip.GetUntangledData(out dataLeft, out dataRight); curveLeft = curveLeft ?? GetCurveFromData(dataLeft, 10000); curveRight = curveRight ?? GetCurveFromData(dataRight, 10000); } EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(string.Format("Start: {0} ({1}s) | End: {2} ({3}s)", info.playRangeStart.Round(0.001), (info.adjustedPlayRangeStart * clip.length).Round(0.001), info.playRangeEnd.Round(0.001), (info.adjustedPlayRangeEnd * clip.length).Round(0.001))); EditorGUILayout.Space(); float labelWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 40; EditorGUILayout.PropertyField(infoProperty.FindPropertyRelative("isFixed"), "Fixed".ToGUIContent(), GUILayout.Width(60)); EditorGUIUtility.labelWidth = labelWidth; EditorGUILayout.EndHorizontal(); EditorGUI.BeginChangeCheck(); EditorGUILayout.MinMaxSlider(ref info.playRangeStart, ref info.playRangeEnd, 0, 1); info.playRangeStart = float.IsNaN(info.playRangeStart) ? 0 : Mathf.Clamp(info.playRangeStart, 0, info.playRangeEnd); info.playRangeEnd = float.IsNaN(info.playRangeEnd) ? 1 : Mathf.Clamp(info.playRangeEnd, info.playRangeStart, 1); if (EditorGUI.EndChangeCheck()) { info.playRangeStart = float.IsNaN(info.playRangeStart) ? 0 : Mathf.Clamp(info.playRangeStart, 0, info.playRangeEnd); info.playRangeEnd = float.IsNaN(info.playRangeEnd) ? 1 : Mathf.Clamp(info.playRangeEnd, info.playRangeStart, 1); for (int i = 0; i < targets.Length; i++) { PureDataSetup selectedSetup = targets[i] as PureDataSetup; if (selectedSetup != null && selectedSetup != setup) { selectedSetup.Info.playRangeStart = float.IsNaN(selectedSetup.Info.playRangeStart) ? 0 : Mathf.Clamp(info.playRangeStart, 0, selectedSetup.Info.playRangeEnd); selectedSetup.Info.playRangeEnd = float.IsNaN(selectedSetup.Info.playRangeEnd) ? 1 : Mathf.Clamp(info.playRangeEnd, selectedSetup.Info.playRangeStart, 1); } } } if (clip.channels > 1) { ShowWaveCurve(curveLeft, 24); ShowWaveCurve(curveRight, 24); } else { ShowWaveCurve(curveLeft, 48); } }
public override void OnEnable() { base.OnEnable(); setup = (PureDataSetup)target; info = setup.Info; infoProperty = serializedObject.FindProperty("info"); clip = setup.Clip; }
void OnSubContainerDropped(PureDataSetup droppedObject) { if (currentSubContainer.type == PureDataSubContainer.Types.AudioSource) { currentSubContainer.Setup = droppedObject; containerManagerSerialized.Update(); } else { OnSubContainerSourceDropped(droppedObject); } }
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 }
public PureDataSubContainer(PureDataContainer container, int parentId, PureDataSetup setup, PureData pureData) { this.name = container.Name; this.id = container.GetUniqueID(); this.parentId = parentId; this.Setup = setup; this.pureData = pureData; switchSettings = new PureDataSwitchSettings(pureData); if (parentId == 0) { container.childrenIds.Add(id); } else { container.GetSubContainerWithID(parentId).childrenIds.Add(id); } }
void ClampFadeOut() { serializedObject.ApplyModifiedProperties(); info.fadeIn = Mathf.Clamp(info.fadeIn, 0, info.adjustedLength - info.fadeOut); info.fadeIn = Mathf.Clamp(info.fadeIn, 0, info.adjustedLength); info.fadeOut = Mathf.Clamp(info.fadeOut, 0, info.adjustedLength); for (int i = 0; i < targets.Length; i++) { PureDataSetup selectedSetup = targets[i] as PureDataSetup; if (selectedSetup != null && selectedSetup != setup) { selectedSetup.Info.fadeIn = Mathf.Clamp(info.fadeIn, 0, selectedSetup.Info.adjustedLength - selectedSetup.Info.fadeOut); selectedSetup.Info.fadeIn = Mathf.Clamp(selectedSetup.Info.fadeIn, 0, selectedSetup.Info.adjustedLength); selectedSetup.Info.fadeOut = Mathf.Clamp(selectedSetup.Info.fadeOut, 0, selectedSetup.Info.adjustedLength); } } }
void ShowOutput() { List <string> options = new List <string>(); options.Add("Master"); options.AddRange(setup.pureData.busManager.buses.GetNames()); EditorGUI.BeginChangeCheck(); info.output = Popup(info.output, options.ToArray(), "Output".ToGUIContent()); if (EditorGUI.EndChangeCheck()) { for (int i = 0; i < targets.Length; i++) { PureDataSetup selectedSetup = targets[i] as PureDataSetup; if (selectedSetup != null && selectedSetup != setup) { selectedSetup.Info.output = info.output; } } } }
void OnSubContainerSourceDropped(PureDataSetup droppedObject) { currentContainer.subContainers.Add(new PureDataSubContainer(currentContainer, currentSubContainer.id, droppedObject, pureData)); containerManagerSerialized.Update(); }
void OnSubContainerDropped(PureDataSetup droppedObject) { if (currentSubContainer.type == PureDataSubContainer.Types.AudioSource) { currentSubContainer.Setup = droppedObject; containerManagerSerialized.Update(); } else { OnSubContainerSourceDropped(droppedObject); } }
void OnContainerSourceDropped(PureDataSetup droppedObject) { AddToArray(subContainersProperty); currentContainer.subContainers[currentContainer.subContainers.Count - 1] = new PureDataSubContainer(currentContainer, 0, droppedObject, pureData); containerManagerSerialized.Update(); }
void OnContainerSourceDropped(PureDataSetup droppedObject) { AddToArray(subContainersProperty); currentContainer.subContainers[currentContainer.subContainers.Count - 1] = new PureDataSubContainer(currentContainer, 0, droppedObject, pureData); containerManagerSerialized.Update(); }
void OnSubContainerSourceDropped(PureDataSetup droppedObject) { currentContainer.subContainers.Add(new PureDataSubContainer(currentContainer, currentSubContainer.id, droppedObject, pureData)); containerManagerSerialized.Update(); }
public PureDataSubContainer(PureDataContainer container, int parentId, PureDataSetup setup, PureData pureData) { this.name = container.Name; this.id = container.GetUniqueID(); this.parentId = parentId; this.Setup = setup; this.pureData = pureData; switchSettings = new PureDataSwitchSettings(pureData); if (parentId == 0) { container.childrenIds.Add(id); } else { container.GetSubContainerWithID(parentId).childrenIds.Add(id); } }
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 }