/// <summary> /// Get all important information of ParameterInstance /// Return a parameterInfo with: /// -ParameterName /// -ParameterRange(start,end) /// </summary> /// <param name="instance">current ParameterInstance</param> /// <returns></returns> private ParameterData GetParameterName(ParameterInstance instance) { ///Create the parameter description ///useflue to get all information PARAMETER_DESCRIPTION desc = new PARAMETER_DESCRIPTION(); instance.getDescription(out desc); ParameterData parameterInfo = new ParameterData(instance, desc.name, desc.minimum, desc.maximum, desc.defaultvalue); return(parameterInfo); }
void OnGUI() { boundactive = false; GUI.depth = -5000; if (editing == this) { if (Vector3.Dot(Camera.main.transform.forward, (transform.position - Camera.main.transform.position).normalized) > 0.1f) { GUI.skin = gskin; Vector3 screenPoint = Camera.main.WorldToScreenPoint(transform.position); screenPoint.x -= 30f; screenPoint.y -= 25f; int height = 120; if (audioSrc.audioInst != null) { int slidercnt = 0; audioSrc.audioInst.getParameterCount(out slidercnt); height = 304 + 25 * slidercnt; } GUI.BeginGroup(new Rect(screenPoint.x, Screen.height - screenPoint.y, 300, height)); GUI.Box(new Rect(0, 0, 300, height), ""); GUILayout.BeginHorizontal(); GUILayout.Space(5); GUILayout.BeginVertical(); GUILayout.Space(8); { GUILayout.Label("Load Event"); GUILayout.BeginHorizontal(); { GUILayout.Space(13); inputPath = GUILayout.TextField(inputPath, GUILayout.Width(200)); if (GUILayout.Button("Load", GUILayout.Width(50))) { audioSrc.path = inputPath; } } GUILayout.EndHorizontal(); GUILayout.Space(15); GUILayout.Label("Audio Settings"); if (audioSrc.audioInst != null) { EventDescription desc = null; audioSrc.audioInst.getDescription(out desc); if (desc != null && desc.isValid()) { bool is3D = false; desc.is3D(out is3D); bool isOneshot = false; desc.isOneshot(out isOneshot); float mindist = 0, maxdist = 0; if (is3D) { desc.getMinimumDistance(out mindist); desc.getMaximumDistance(out maxdist); boundactive = true; bound.transform.localScale = Vector3.one * audioSrc.maxDistance * 2f; } string is3Dstr = is3D ? "3D Sound" : "2D Sound"; string diststr = is3D ? ("Distance Area ( " + mindist.ToString("0.##") + "m ~ " + maxdist.ToString("0.##") + "m )") : (""); if (listener != null) { LabelField("Distance", listenDist.ToString("#,##0.00") + " m"); } else { LabelField("Distance", "-"); } LabelField(is3Dstr, diststr); audioSrc.minDistance = FloatField("Min Dist", audioSrc.minDistance); audioSrc.maxDistance = FloatField("Max Dist", audioSrc.maxDistance); LabelField("Is Oneshot", isOneshot.ToString()); audioSrc.volume = Slider("Volume", audioSrc.volume, 0f, 1f); audioSrc.pitch = Slider("Pitch", audioSrc.pitch, 0f, 4f); int pcnt = 0; audioSrc.audioInst.getParameterCount(out pcnt); for (int i = 0; i < pcnt; ++i) { ParameterInstance pinst = null; audioSrc.audioInst.getParameterByIndex(i, out pinst); PARAMETER_DESCRIPTION pdesc = new PARAMETER_DESCRIPTION(); pinst.getDescription(out pdesc); float val = 0f, _val = 0f; pinst.getValue(out val); _val = Slider(pdesc.name, val, pdesc.minimum, pdesc.maximum); if (_val != val) { pinst.setValue(_val); } } GUILayout.Space(8); GUILayout.BeginHorizontal(); { GUILayout.Space(17); if (GUILayout.Button("Play", GUILayout.Width(80))) { audioSrc.Play(); } GUILayout.Space(4); if (GUILayout.Button("Stop", GUILayout.Width(80))) { audioSrc.Stop(); } GUILayout.Space(4); if (GUILayout.Button("Unload", GUILayout.Width(80))) { audioSrc.path = ""; } } GUILayout.EndHorizontal(); } } else { GUILayout.BeginHorizontal(); { GUILayout.Space(13); GUILayout.Label("No Event Loaded"); } GUILayout.EndHorizontal(); } } GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUI.EndGroup(); } else { if (audioSrc.is3D) { boundactive = true; bound.transform.localScale = Vector3.one * audioSrc.maxDistance * 2f; } } } }