Skip to content

Commit 73c16d0

Browse files
author
Unity Technologies
committed
Unity 6000.0.15f1 C# reference source code
1 parent 7ab3b49 commit 73c16d0

File tree

98 files changed

+1206
-780
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+1206
-780
lines changed

Editor/Mono/AssetStore/AssetStorePreviewManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public static int Downloading
107107

108108
public static string StatsString()
109109
{
110-
return string.Format("Reqs: {0}, Ok: {1}, Abort: {2}, CacheDel: {3}, Cache: {4}/{5}, CacheHit: {6}",
110+
return string.Format("Reqs: {0}, OK: {1}, Abort: {2}, CacheDel: {3}, Cache: {4}/{5}, CacheHit: {6}",
111111
Instance.Requested, Instance.m_Success, Instance.m_Aborted, Instance.m_CacheRemove,
112112
AssetStorePreviewManager.CachedAssetStoreImages.Count,
113113
Instance.m_MaxCachedAssetStoreImages,

Editor/Mono/Audio/AudioContainerWindow.cs

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ void SubscribeToGUICallbacksAndEvents()
298298
SubscribeToClipListCallbacksAndEvents();
299299
SubscribeToAutomaticTriggerCallbacksAndEvents();
300300
SubscribeToTooltipCallbacksAndEvents();
301+
SubscribeToAudioMasterMuteCallbacksAndEvents();
301302
m_IsSubscribedToGUICallbacksAndEvents = true;
302303
}
303304

@@ -314,6 +315,7 @@ void UnsubscribeFromGUICallbacksAndEvents()
314315
UnsubscribeFromClipListCallbacksAndEvents();
315316
UnsubscribeFromAutomaticTriggerCallbacksAndEvents();
316317
UnsubscribeFromTooltipCallbacksAndEvents();
318+
UnsubscribeFromAudioMasterMuteCallbacksAndEvents();
317319
m_IsSubscribedToGUICallbacksAndEvents = false;
318320
}
319321

@@ -425,8 +427,8 @@ void UpdateTransportButtonStates()
425427
{
426428
var editorIsPaused = EditorApplication.isPaused;
427429

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);
430432

431433
var image =
432434
State.IsPlayingOrPaused()
@@ -1126,27 +1128,44 @@ void SubscribeToTooltipCallbacksAndEvents()
11261128
rootVisualElement.RegisterCallback<TooltipEvent>(ShowTooltip, TrickleDown.TrickleDown);
11271129
}
11281130

1131+
void SubscribeToAudioMasterMuteCallbacksAndEvents()
1132+
{
1133+
EditorUtility.onAudioMasterMuteWasUpdated += OnAudioMasterMuteChanged;
1134+
}
1135+
11291136
void UnsubscribeFromTooltipCallbacksAndEvents()
11301137
{
11311138
rootVisualElement.UnregisterCallback<TooltipEvent>(ShowTooltip);
11321139
}
11331140

1141+
void UnsubscribeFromAudioMasterMuteCallbacksAndEvents()
1142+
{
1143+
EditorUtility.onAudioMasterMuteWasUpdated -= OnAudioMasterMuteChanged;
1144+
}
1145+
11341146
void ShowTooltip(TooltipEvent evt)
11351147
{
11361148
var name = (evt.target as VisualElement).name;
11371149

11381150
if (name == "play-button" || name == "play-button-image")
11391151
{
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)
11441153
{
1145-
evt.tooltip = mode;
1154+
evt.tooltip = "Previewing is disabled when the game view is muted. To enable previewing unmute the game view.";
11461155
}
11471156
else
11481157
{
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+
}
11501169
}
11511170

11521171
evt.rect = (evt.target as VisualElement).worldBound;
@@ -1267,6 +1286,17 @@ void OnCountRandomizationButtonClicked()
12671286
State.AudioContainer.loopCountRandomizationEnabled = !State.AudioContainer.loopCountRandomizationEnabled;
12681287
}
12691288

1289+
void OnAudioMasterMuteChanged(bool isMuted)
1290+
{
1291+
if (isMuted && State.IsPlayingOrPaused())
1292+
{
1293+
State.Stop();
1294+
ClearClipFieldProgressBars();
1295+
}
1296+
1297+
UpdateTransportButtonStates();
1298+
}
1299+
12701300
#endregion
12711301

12721302
#region GlobalEditorCallbackHandlers
@@ -1425,7 +1455,7 @@ static void Preview(ShortcutArguments args)
14251455
{
14261456
var audioContainerWindow = focusedWindow as AudioContainerWindow;
14271457

1428-
if (audioContainerWindow != null && audioContainerWindow.IsDisplayingTarget())
1458+
if (audioContainerWindow != null && audioContainerWindow.IsDisplayingTarget() && !EditorUtility.audioMasterMute)
14291459
{
14301460
audioContainerWindow.OnPlayStopButtonClicked();
14311461
}

Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ static public void LaunchOnTargets(BuildTarget buildTarget, BuildReport buildRep
215215
catch (DeploymentOperationFailedException e)
216216
{
217217
UnityEngine.Debug.LogException(e);
218-
EditorUtility.DisplayDialog(e.title, e.Message, "Ok");
218+
EditorUtility.DisplayDialog(e.title, e.Message, "OK");
219219
}
220220
catch (DeploymentOperationAbortedException)
221221
{

Editor/Mono/BuildPlayerWindowBuildMethods.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ private static bool PickBuildLocation(BuildTargetGroup targetGroup, BuildTarget
341341
{
342342
isValidPath = true;
343343
}
344-
else if (!EditorUtility.DisplayDialog("Invalid build path", msg, "Ok", "Cancel"))
344+
else if (!EditorUtility.DisplayDialog("Invalid build path", msg, "OK", "Cancel"))
345345
{
346346
Debug.LogError($"Invalid build path: '{path}'. {msg}");
347347
return false;

Editor/Mono/BuildProfile/BuildProfile.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ namespace UnityEditor.Build.Profile
1919
[StructLayout(LayoutKind.Sequential)]
2020
[ExcludeFromObjectFactory]
2121
[ExcludeFromPreset]
22+
[HelpURL("build-profiles-reference")]
2223
public sealed partial class BuildProfile : ScriptableObject
2324
{
2425
/// <summary>
@@ -127,6 +128,9 @@ internal PlayerSettings playerSettings
127128
set { m_PlayerSettings = value; }
128129
}
129130

131+
[VisibleToOtherModules]
132+
internal Action OnPlayerSettingsUpdatedFromYAML;
133+
130134
// TODO: Return server IBuildTargets for server build profiles. (https://jira.unity3d.com/browse/PLAT-6612)
131135
/// <summary>
132136
/// Get the IBuildTarget of the build profile.
@@ -202,14 +206,10 @@ void OnEnable()
202206

203207
void OnDisable()
204208
{
205-
RemovePlayerSettings();
206-
207-
// Active profile YAML may be read from disk during startup or
208-
// Asset Database refresh, flush pending changes to disk.
209-
if (BuildProfileContext.instance.activeProfile != this)
210-
return;
211-
212-
AssetDatabase.SaveAssetIfDirty(this);
209+
// OnDisable is called when entering play mode, during domain reloads, or when the object is destroyed.
210+
// Avoid removing player settings for the first two cases to prevent slow syncs (e.g., color space) caused by global manager updates.
211+
if (!EditorApplication.isUpdating)
212+
RemovePlayerSettings();
213213
}
214214

215215
[MenuItem("CONTEXT/BuildProfile/Reset", false)]

Editor/Mono/BuildProfile/BuildProfileContext.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,26 @@ static string GetActiveBuildProfilePath()
634634
return string.Empty;
635635
}
636636

637+
[RequiredByNativeCode]
638+
static bool HasActiveProfileWithPlayerSettings(out int instanceID)
639+
{
640+
var activeProfile = instance.activeProfile;
641+
if (activeProfile?.playerSettings != null)
642+
{
643+
instanceID = activeProfile.GetInstanceID();
644+
return true;
645+
}
646+
647+
instanceID = 0;
648+
return false;
649+
}
650+
651+
[RequiredByNativeCode]
652+
static void UpdateActiveProfilePlayerSettingsObjectFromYAML()
653+
{
654+
instance.activeProfile?.UpdatePlayerSettingsObjectFromYAML();
655+
}
656+
637657
static bool ShouldReturnActiveProfile(BuildTarget buildTarget, StandaloneBuildSubtarget subtarget, string sharedSetting = null)
638658
{
639659
if (!string.IsNullOrEmpty(sharedSetting))

Editor/Mono/BuildProfile/BuildProfilePlayerSettings.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,15 @@ internal void LoadPlayerSettings()
8282
DeserializePlayerSettings();
8383
}
8484

85+
internal void UpdatePlayerSettingsObjectFromYAML()
86+
{
87+
if (!HasSerializedPlayerSettings())
88+
return;
89+
90+
PlayerSettings.UpdatePlayerSettingsObjectFromYAML(playerSettings, m_PlayerSettingsYaml.GetYamlString());
91+
OnPlayerSettingsUpdatedFromYAML?.Invoke();
92+
}
93+
8594
internal void CreatePlayerSettingsFromGlobal()
8695
{
8796
if (m_PlayerSettings != null || BuildProfileContext.IsClassicPlatformProfile(this))
@@ -102,6 +111,8 @@ internal void RemovePlayerSettings(bool clearYaml = false)
102111
if (BuildProfileContext.IsClassicPlatformProfile(this))
103112
return;
104113

114+
UpdateGlobalManagerPlayerSettings(activeWillBeRemoved: true);
115+
105116
if (m_PlayerSettings != null)
106117
{
107118
DestroyImmediate(m_PlayerSettings, true);
@@ -112,7 +123,7 @@ internal void RemovePlayerSettings(bool clearYaml = false)
112123
m_PlayerSettingsYaml.Clear();
113124
}
114125

115-
UpdateGlobalManagerPlayerSettings(activeWillBeRemoved: true);
126+
OnPlayerSettingsUpdatedFromYAML?.Invoke();
116127
}
117128

118129
internal static void CleanUpPlayerSettingsForDeletedBuildProfiles(IList<BuildProfile> currentBuildProfiles)
@@ -160,7 +171,10 @@ internal void DeserializePlayerSettings()
160171
if (!HasSerializedPlayerSettings())
161172
return;
162173

163-
m_PlayerSettings = PlayerSettings.DeserializeFromYAMLString(m_PlayerSettingsYaml.GetYamlString());
174+
if (m_PlayerSettings == null)
175+
m_PlayerSettings = PlayerSettings.DeserializeFromYAMLString(m_PlayerSettingsYaml.GetYamlString());
176+
else
177+
UpdatePlayerSettingsObjectFromYAML();
164178
s_LoadedPlayerSettings.Add(m_PlayerSettings);
165179
UpdateGlobalManagerPlayerSettings();
166180
}

Editor/Mono/EditorUtility.bindings.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,28 @@ public static bool ExtractOggFile(Object obj, string path)
241241
[FreeFunction("GetApplication().GetActiveNativePlatformSupportModuleName")]
242242
internal static extern string GetActiveNativePlatformSupportModuleName();
243243

244-
public static extern bool audioMasterMute
244+
internal static extern bool Internal_AudioMasterMute
245245
{
246246
[FreeFunction("GetAudioManager().GetMasterGroupMute")] get;
247247
[FreeFunction("GetAudioManager().SetMasterGroupMute")] set;
248248
}
249249

250+
public static bool audioMasterMute
251+
{
252+
get { return Internal_AudioMasterMute; }
253+
set
254+
{
255+
if (value != Internal_AudioMasterMute)
256+
{
257+
Internal_AudioMasterMute = value;
258+
onAudioMasterMuteWasUpdated?.Invoke(value);
259+
}
260+
}
261+
}
262+
263+
internal delegate void AudioMasterMuteWasUpdated(bool value);
264+
internal static event AudioMasterMuteWasUpdated onAudioMasterMuteWasUpdated;
265+
250266
internal static extern void LaunchBugReporter();
251267

252268
internal static extern bool audioProfilingEnabled

Editor/Mono/GUI/ManagedDebuggerWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ private static void OnDebuggerAttached(bool debuggerAttached)
108108
EditorUtility.DisplayDialog(
109109
"C# Debugger Attached",
110110
"All compiler errors must be fixed before switching to debug mode.",
111-
"Ok");
111+
"OK");
112112
ManagedDebugger.Disconnect();
113113
}
114114
else

Editor/Mono/Handles/HandleUtility.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1904,12 +1904,13 @@ internal static void FilterRendererIDs(Renderer[] renderers, out int[] parentRen
19041904
childRendererIDs = tempChildRendererIDs.ToArray();
19051905
}
19061906

1907-
internal static void FilterInstanceIDs(IEnumerable<GameObject> gameObjects, out int[] parentInstanceIDs, out int[] childInstanceIDs)
1907+
internal static void FilterInstanceIDs(IEnumerable<GameObject> gameObjects, out int[] parentInstanceIDs, out int[] childInstanceIDs, out HashSet<int> childInstanceIDsHashSet)
19081908
{
19091909
if (gameObjects.Count() == 0)
19101910
{
19111911
parentInstanceIDs = new int[0];
19121912
childInstanceIDs = new int[0];
1913+
childInstanceIDsHashSet = null;
19131914
return;
19141915
}
19151916

@@ -1924,23 +1925,23 @@ internal static void FilterInstanceIDs(IEnumerable<GameObject> gameObjects, out
19241925
tempParentInstanceIDs.Add(go.GetInstanceID());
19251926
}
19261927

1927-
var tempChildInstanceIDs = new HashSet<int>();
1928+
childInstanceIDsHashSet = new HashSet<int>();
19281929
foreach (var go in gameObjects)
19291930
{
19301931
var childRenderers = go.GetComponentsInChildren<Renderer>();
19311932
for (int i = 0; i < childRenderers.Length; i++)
19321933
{
19331934
var id = childRenderers[i].GetInstanceID();
19341935
if (!tempParentInstanceIDs.Contains(id))
1935-
tempChildInstanceIDs.Add(id);
1936+
childInstanceIDsHashSet.Add(id);
19361937
}
19371938

19381939
var childTerrains = go.GetComponentsInChildren<Terrain>();
19391940
for (int i = 0; i < childTerrains.Length; i++)
19401941
{
19411942
var id = childTerrains[i].GetInstanceID();
19421943
if (!tempParentInstanceIDs.Contains(id))
1943-
tempChildInstanceIDs.Add(id);
1944+
childInstanceIDsHashSet.Add(id);
19441945
}
19451946

19461947
// Script components can issue Render commands that are rendered in the outline so we need to take that in account
@@ -1952,12 +1953,12 @@ internal static void FilterInstanceIDs(IEnumerable<GameObject> gameObjects, out
19521953
continue;
19531954
var id = script.gameObject.GetInstanceID();
19541955
if (!tempParentInstanceIDs.Contains(id))
1955-
tempChildInstanceIDs.Add(id);
1956+
childInstanceIDsHashSet.Add(id);
19561957
}
19571958
}
19581959

19591960
parentInstanceIDs = tempParentInstanceIDs.ToArray();
1960-
childInstanceIDs = tempChildInstanceIDs.ToArray();
1961+
childInstanceIDs = childInstanceIDsHashSet.ToArray();
19611962
}
19621963

19631964
static bool HasMatchingInstanceID(int[] ids, int id, int cutoff)

Editor/Mono/Handles/Handles.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,7 +1470,7 @@ public static void DrawOutline(Renderer[] renderers, Color color, float fillOpac
14701470
public static void DrawOutline(GameObject[] objects, Color parentNodeColor, Color childNodeColor, float fillOpacity = 0)
14711471
{
14721472
int[] parentRenderers, childRenderers;
1473-
HandleUtility.FilterInstanceIDs(objects, out parentRenderers, out childRenderers);
1473+
HandleUtility.FilterInstanceIDs(objects, out parentRenderers, out childRenderers, out _);
14741474
DrawOutline(parentRenderers, childRenderers, parentNodeColor, childNodeColor, fillOpacity);
14751475
}
14761476

@@ -1487,7 +1487,7 @@ public static void DrawOutline(GameObject[] objects, Color color, float fillOpac
14871487
public static void DrawOutline(List<GameObject> objects, Color parentNodeColor, Color childNodeColor, float fillOpacity = 0)
14881488
{
14891489
int[] parentRenderers, childRenderers;
1490-
HandleUtility.FilterInstanceIDs((GameObject[])NoAllocHelpers.ExtractArrayFromList(objects), out parentRenderers, out childRenderers);
1490+
HandleUtility.FilterInstanceIDs((GameObject[])NoAllocHelpers.ExtractArrayFromList(objects), out parentRenderers, out childRenderers, out _);
14911491
DrawOutline(parentRenderers, childRenderers, parentNodeColor, childNodeColor, fillOpacity);
14921492
}
14931493

@@ -1516,7 +1516,7 @@ internal static void DrawOutlineOrWireframeInternal(Color parentNodeColor, Color
15161516
internal static void DrawSubmeshOutline(Color parentNodeColor, Color childNodeColor, float outlineAlpha, int submeshOutlineMaterialId)
15171517
{
15181518
int[] parentRenderers, childRenderers;
1519-
HandleUtility.FilterInstanceIDs(Selection.gameObjects, out parentRenderers, out childRenderers);
1519+
HandleUtility.FilterInstanceIDs(Selection.gameObjects, out parentRenderers, out childRenderers, out _);
15201520

15211521
// RenderOutline will swap color.a and outlineAlpha so we reverse it here to preserve correct behavior wrt Color settings in Preferences
15221522
var parentOutlineAlpha = parentNodeColor.a;

Editor/Mono/Inspector/AvatarPreviewSelection.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ static public void SetPreview(ModelImporterAnimationType type, GameObject go)
3030
if (instance.m_PreviewModels[(int)type] != go)
3131
{
3232
instance.m_PreviewModels[(int)type] = go;
33-
instance.Save(false);
3433
}
3534
}
3635

0 commit comments

Comments
 (0)