-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expand file tree
/
Copy pathAudioMixerExposedParametersPopup.cs
More file actions
61 lines (54 loc) · 2.41 KB
/
AudioMixerExposedParametersPopup.cs
File metadata and controls
61 lines (54 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Unity C# reference source
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
using System;
using UnityEngine;
using UnityEditorInternal;
using UnityEditor.Audio;
namespace UnityEditor
{
internal partial class AudioMixerExposedParametersPopup : PopupWindowContent
{
// Shows pop up
internal static void Popup(AudioMixerController controller, GUIStyle style, params GUILayoutOption[] options)
{
GUIContent content = GetButtonContent(controller);
Rect buttonRect = GUILayoutUtility.GetRect(content, style, options);
if (EditorGUI.DropdownButton(buttonRect, content, FocusType.Passive, style))
{
PopupWindow.Show(buttonRect, new AudioMixerExposedParametersPopup(controller));
}
}
// Cache to prevent constructing string on every event
static GUIContent m_ButtonContent = EditorGUIUtility.TrTextContent("", "Audio Mixer parameters can be exposed to scripting. Select an Audio Mixer Group, right click one of its properties in the Inspector and select 'Expose ..'.");
static int m_LastNumExposedParams = -1;
static GUIContent GetButtonContent(AudioMixerController controller)
{
if (controller.numExposedParameters != m_LastNumExposedParams)
{
m_ButtonContent.text = string.Format("Exposed Parameters ({0})", controller.numExposedParameters);
m_LastNumExposedParams = controller.numExposedParameters;
}
return m_ButtonContent;
}
//
private readonly AudioMixerExposedParameterView m_ExposedParametersView;
AudioMixerExposedParametersPopup(AudioMixerController controller)
{
m_ExposedParametersView = new AudioMixerExposedParameterView(new ReorderableListWithRenameAndScrollView.State());
m_ExposedParametersView.OnMixerControllerChanged(controller);
}
public override void OnGUI(Rect rect)
{
m_ExposedParametersView.OnEvent();
m_ExposedParametersView.OnGUI(rect);
}
public override Vector2 GetWindowSize()
{
Vector2 size = m_ExposedParametersView.CalcSize();
size.x = Math.Max(size.x, 125f);
size.y = Math.Max(size.y, 23f);
return size;
}
}
} // namespace