@@ -42,6 +42,8 @@ private struct ActionEntry
42
42
public float Volume ;
43
43
public float Pitch ;
44
44
public float SpatialBlend ;
45
+
46
+ public float ListenerDistance ;
45
47
}
46
48
47
49
private bool m_ListenForEvents = true ;
@@ -55,6 +57,8 @@ private struct ActionEntry
55
57
56
58
private Vector2 m_ScrollView ;
57
59
60
+ private AudioListener m_AudioListener ;
61
+
58
62
public static void ShowMonitor ( )
59
63
{
60
64
var window = GetWindow < AudioSourcePlayerMonitorWindow > ( false , "Audio Monitor" ) ;
@@ -107,6 +111,10 @@ private void AddAction(ActionType actionType, AudioSourcePlayer player)
107
111
if ( ! m_ListenForEvents )
108
112
return ;
109
113
114
+ if ( m_AudioListener == null || ! m_AudioListener . isActiveAndEnabled ) {
115
+ m_AudioListener = GameObject . FindAnyObjectByType < AudioListener > ( ) ;
116
+ }
117
+
110
118
m_Actions . Add ( new ActionEntry ( ) {
111
119
Type = actionType ,
112
120
Time = Time . time ,
@@ -124,6 +132,7 @@ private void AddAction(ActionType actionType, AudioSourcePlayer player)
124
132
Pitch = player . Pitch ,
125
133
SpatialBlend = player . SpatialBlend ,
126
134
135
+ ListenerDistance = m_AudioListener ? Vector3 . Distance ( m_AudioListener . transform . position , player . transform . position ) : - 1f ,
127
136
} ) ;
128
137
129
138
if ( m_Actions . Count > m_EntriesLimit ) {
@@ -156,6 +165,7 @@ private void OnUIAudioEffectsPlayed(UIAudioEffects uiAudioEffects, AudioResource
156
165
Pitch = uiAudioEffects . AudioSource ? . pitch ?? 1f ,
157
166
SpatialBlend = uiAudioEffects . AudioSource ? . spatialBlend ?? 0f ,
158
167
168
+ ListenerDistance = - 1f ,
159
169
} ) ;
160
170
161
171
if ( m_Actions . Count > m_EntriesLimit ) {
@@ -189,17 +199,19 @@ void OnGUI()
189
199
190
200
GUI . backgroundColor = prevBackgroundColor ;
191
201
192
- m_EntriesLimit = Mathf . Max ( 0 , EditorGUILayout . IntField ( "Limit Entries" , m_EntriesLimit , GUILayout . ExpandWidth ( false ) ) ) ;
193
-
194
202
GUI . backgroundColor = m_ShowDetails ? Color . green : prevBackgroundColor ;
195
203
if ( GUILayout . Button ( "Details" , GUILayout . ExpandWidth ( false ) ) ) {
196
204
m_ShowDetails = ! m_ShowDetails ;
197
205
}
198
206
GUI . backgroundColor = prevBackgroundColor ;
199
207
208
+ float prevLabelWidth = EditorGUIUtility . labelWidth ;
209
+ EditorGUIUtility . labelWidth = 80f ;
210
+ m_EntriesLimit = Mathf . Max ( 0 , EditorGUILayout . IntField ( "Limit Entries" , m_EntriesLimit , GUILayout . Width ( 112f ) ) ) ;
211
+ EditorGUIUtility . labelWidth = prevLabelWidth ;
212
+
200
213
GUILayout . FlexibleSpace ( ) ;
201
214
202
- float prevLabelWidth = EditorGUIUtility . labelWidth ;
203
215
EditorGUIUtility . labelWidth = 80f ;
204
216
m_ClearOnPlay = EditorGUILayout . Toggle ( "Clear on play" , m_ClearOnPlay ) ;
205
217
EditorGUIUtility . labelWidth = prevLabelWidth ;
@@ -228,10 +240,11 @@ private void DrawSimpleView()
228
240
EditorGUILayout . BeginHorizontal ( ) ;
229
241
{
230
242
GUILayout . Label ( "Action" , HeaderStyle , GUILayout . Width ( enumColumnWidth ) ) ;
231
- GUILayout . Label ( "Time" , HeaderStyle , GUILayout . Width ( timeColumnWidth ) ) ;
243
+ GUILayout . Label ( "Time" , HeaderStyle , GUILayout . MaxWidth ( timeColumnWidth ) ) ;
232
244
233
245
GUILayout . Label ( "Player" , HeaderStyle , GUILayout . ExpandWidth ( true ) ) ;
234
246
GUILayout . Label ( "Resource" , HeaderStyle , GUILayout . ExpandWidth ( true ) ) ;
247
+ GUILayout . Label ( "Distance" , HeaderStyle , GUILayout . MaxWidth ( timeColumnWidth ) ) ;
235
248
}
236
249
EditorGUILayout . EndHorizontal ( ) ;
237
250
@@ -249,9 +262,10 @@ private void DrawSimpleView()
249
262
EditorGUILayout . BeginHorizontal ( ) ;
250
263
{
251
264
GUILayout . Label ( action . Type . ToString ( ) , EditorStyles . boldLabel , GUILayout . Width ( enumColumnWidth ) ) ;
252
- EditorGUILayout . FloatField ( action . Time , GUILayout . Width ( timeColumnWidth ) ) ;
265
+ EditorGUILayout . FloatField ( action . Time , GUILayout . MaxWidth ( timeColumnWidth ) ) ;
253
266
EditorGUILayout . ObjectField ( action . Player , action . Player ? . GetType ( ) , true , GUILayout . ExpandWidth ( true ) ) ;
254
267
EditorGUILayout . ObjectField ( action . Resource , audioType , true , GUILayout . ExpandWidth ( true ) ) ;
268
+ EditorGUILayout . FloatField ( action . ListenerDistance , GUILayout . MaxWidth ( timeColumnWidth ) ) ;
255
269
256
270
}
257
271
EditorGUILayout . EndHorizontal ( ) ;
0 commit comments