@@ -298,6 +298,7 @@ void SubscribeToGUICallbacksAndEvents()
298
298
SubscribeToClipListCallbacksAndEvents ( ) ;
299
299
SubscribeToAutomaticTriggerCallbacksAndEvents ( ) ;
300
300
SubscribeToTooltipCallbacksAndEvents ( ) ;
301
+ SubscribeToAudioMasterMuteCallbacksAndEvents ( ) ;
301
302
m_IsSubscribedToGUICallbacksAndEvents = true ;
302
303
}
303
304
@@ -314,6 +315,7 @@ void UnsubscribeFromGUICallbacksAndEvents()
314
315
UnsubscribeFromClipListCallbacksAndEvents ( ) ;
315
316
UnsubscribeFromAutomaticTriggerCallbacksAndEvents ( ) ;
316
317
UnsubscribeFromTooltipCallbacksAndEvents ( ) ;
318
+ UnsubscribeFromAudioMasterMuteCallbacksAndEvents ( ) ;
317
319
m_IsSubscribedToGUICallbacksAndEvents = false ;
318
320
}
319
321
@@ -425,8 +427,8 @@ void UpdateTransportButtonStates()
425
427
{
426
428
var editorIsPaused = EditorApplication . isPaused ;
427
429
428
- m_PlayStopButton ? . SetEnabled ( State . IsReadyToPlay ( ) && ! editorIsPaused ) ;
429
- m_SkipButton ? . SetEnabled ( State . IsPlayingOrPaused ( ) && State . AudioContainer . triggerMode == AudioRandomContainerTriggerMode . Automatic && ! editorIsPaused ) ;
430
+ m_PlayStopButton ? . SetEnabled ( State . IsReadyToPlay ( ) && ! editorIsPaused && ! EditorUtility . audioMasterMute ) ;
431
+ m_SkipButton ? . SetEnabled ( State . IsPlayingOrPaused ( ) && State . AudioContainer . triggerMode == AudioRandomContainerTriggerMode . Automatic && ! editorIsPaused && ! EditorUtility . audioMasterMute ) ;
430
432
431
433
var image =
432
434
State . IsPlayingOrPaused ( )
@@ -1126,27 +1128,44 @@ void SubscribeToTooltipCallbacksAndEvents()
1126
1128
rootVisualElement . RegisterCallback < TooltipEvent > ( ShowTooltip , TrickleDown . TrickleDown ) ;
1127
1129
}
1128
1130
1131
+ void SubscribeToAudioMasterMuteCallbacksAndEvents ( )
1132
+ {
1133
+ EditorUtility . onAudioMasterMuteWasUpdated += OnAudioMasterMuteChanged ;
1134
+ }
1135
+
1129
1136
void UnsubscribeFromTooltipCallbacksAndEvents ( )
1130
1137
{
1131
1138
rootVisualElement . UnregisterCallback < TooltipEvent > ( ShowTooltip ) ;
1132
1139
}
1133
1140
1141
+ void UnsubscribeFromAudioMasterMuteCallbacksAndEvents ( )
1142
+ {
1143
+ EditorUtility . onAudioMasterMuteWasUpdated -= OnAudioMasterMuteChanged ;
1144
+ }
1145
+
1134
1146
void ShowTooltip ( TooltipEvent evt )
1135
1147
{
1136
1148
var name = ( evt . target as VisualElement ) . name ;
1137
1149
1138
1150
if ( name == "play-button" || name == "play-button-image" )
1139
1151
{
1140
- var mode = State . IsPlayingOrPaused ( ) ? "Stop" : "Play" ;
1141
- var shortcut = ShortcutManager . instance . GetShortcutBinding ( "Audio/Play-stop Audio Random Container" ) ;
1142
-
1143
- if ( shortcut . Equals ( ShortcutBinding . empty ) )
1152
+ if ( EditorUtility . audioMasterMute )
1144
1153
{
1145
- evt . tooltip = mode ;
1154
+ evt . tooltip = "Previewing is disabled when the game view is muted. To enable previewing unmute the game view." ;
1146
1155
}
1147
1156
else
1148
1157
{
1149
- evt . tooltip = mode + " (" + shortcut + ")" ;
1158
+ var mode = State . IsPlayingOrPaused ( ) ? "Stop" : "Play" ;
1159
+ var shortcut = ShortcutManager . instance . GetShortcutBinding ( "Audio/Play-stop Audio Random Container" ) ;
1160
+
1161
+ if ( shortcut . Equals ( ShortcutBinding . empty ) )
1162
+ {
1163
+ evt . tooltip = mode ;
1164
+ }
1165
+ else
1166
+ {
1167
+ evt . tooltip = mode + " (" + shortcut + ")" ;
1168
+ }
1150
1169
}
1151
1170
1152
1171
evt . rect = ( evt . target as VisualElement ) . worldBound ;
@@ -1267,6 +1286,17 @@ void OnCountRandomizationButtonClicked()
1267
1286
State . AudioContainer . loopCountRandomizationEnabled = ! State . AudioContainer . loopCountRandomizationEnabled ;
1268
1287
}
1269
1288
1289
+ void OnAudioMasterMuteChanged ( bool isMuted )
1290
+ {
1291
+ if ( isMuted && State . IsPlayingOrPaused ( ) )
1292
+ {
1293
+ State . Stop ( ) ;
1294
+ ClearClipFieldProgressBars ( ) ;
1295
+ }
1296
+
1297
+ UpdateTransportButtonStates ( ) ;
1298
+ }
1299
+
1270
1300
#endregion
1271
1301
1272
1302
#region GlobalEditorCallbackHandlers
@@ -1425,7 +1455,7 @@ static void Preview(ShortcutArguments args)
1425
1455
{
1426
1456
var audioContainerWindow = focusedWindow as AudioContainerWindow ;
1427
1457
1428
- if ( audioContainerWindow != null && audioContainerWindow . IsDisplayingTarget ( ) )
1458
+ if ( audioContainerWindow != null && audioContainerWindow . IsDisplayingTarget ( ) && ! EditorUtility . audioMasterMute )
1429
1459
{
1430
1460
audioContainerWindow . OnPlayStopButtonClicked ( ) ;
1431
1461
}
0 commit comments