Skip to content

Commit 18d6ef1

Browse files
author
Unity Technologies
committed
Unity 6000.1.0a5 C# reference source code
1 parent 9cecb4a commit 18d6ef1

34 files changed

+817
-55
lines changed

Editor/Mono/AssemblyReloadEvents.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,23 @@ public static event AssemblyReloadCallback afterAssemblyReload
2727
[RequiredByNativeCode]
2828
static void OnBeforeAssemblyReload()
2929
{
30+
using var scope = new ProgressScope("OnBeforeAssemblyReload Callback", "", forceShow: true);
3031
foreach (var evt in m_BeforeAssemblyReloadEvent)
32+
{
33+
scope.SetText($"{evt.Method?.DeclaringType?.FullName}.{evt.Method?.Name}", true);
3134
evt();
35+
}
3236
}
3337

3438
[RequiredByNativeCode]
3539
static void OnAfterAssemblyReload()
3640
{
41+
using var scope = new ProgressScope("OnAfterAssemblyReload Callback", "", forceShow: true);
3742
foreach (var evt in m_AfterAssemblyReloadEvent)
43+
{
44+
scope.SetText($"{evt.Method?.DeclaringType?.FullName}.{evt.Method?.Name}", true);
3845
evt();
46+
}
3947
}
4048
}
4149
}

Editor/Mono/EditorApplication.bindings.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,5 +367,14 @@ internal static extern GUID buildSessionGUID
367367
[FreeFunction("GetBuildSettings().GetBuildSessionGUID")]
368368
get;
369369
}
370+
371+
public static extern bool isFocused
372+
{
373+
[StaticAccessor("GetApplication()", StaticAccessorType.Dot)]
374+
get;
375+
376+
[StaticAccessor("GetApplication()", StaticAccessorType.Dot)]
377+
private set;
378+
}
370379
}
371380
}

Editor/Mono/EditorApplication.cs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,6 @@ public static event Action<PlayModeStateChange> playModeStateChanged
284284
internal static Func<bool> doPressedKeysTriggerAnyShortcut;
285285

286286
public static event Action<bool> focusChanged;
287-
public static bool isFocused { get; private set; }
288287

289288
// Windows were reordered
290289
internal static CallbackFunction windowsReordered;
@@ -477,8 +476,12 @@ static void Internal_PauseStateChanged(PauseState state)
477476
playmodeStateChanged?.Invoke();
478477
#pragma warning restore 618
479478

479+
using var scope = new ProgressScope($"PauseStateChanged Callback", "" , forceShow: true);
480480
foreach (var evt in m_PauseStateChangedEvent)
481+
{
482+
scope.SetText($"{evt.Method?.DeclaringType?.FullName}.{evt.Method?.Name}", true);
481483
evt(state);
484+
}
482485
}
483486

484487
[RequiredByNativeCode]
@@ -487,9 +490,28 @@ static void Internal_PlayModeStateChanged(PlayModeStateChange state)
487490
#pragma warning disable 618
488491
playmodeStateChanged?.Invoke();
489492
#pragma warning restore 618
490-
493+
if (!m_PlayModeStateChangedEvent.hasSubscribers) return;
494+
var stateName = state.ToString();
495+
496+
// Without this workaround, you will fail Editor.GameViewTests.Playmode_PlayUnfocused_IsUnfocused_WhenGameViewFocused
497+
// You can still trigger UUM-74498 by showing a ProgressScope in EnteredPlayMode (including in usercode with EditorUtility.DisplayProgressBar)
498+
// This is because a progress bar going away will cause the previously focused window to be refocused
499+
// The underlying issue is being tracked in UUM-86918 and this workaround should be undone as part of the fix there
500+
if (PlayModeView.GetMainPlayModeView() is GameView { enterPlayModeBehavior: PlayModeView.EnterPlayModeBehavior.PlayUnfocused }
501+
&& state == PlayModeStateChange.EnteredPlayMode)
502+
{
503+
foreach (var evt in m_PlayModeStateChangedEvent)
504+
{
505+
evt(state);
506+
}
507+
return;
508+
}
509+
using var scope = new ProgressScope($"PlayModeStateChanged Callback ({stateName})", "", forceShow: true);
491510
foreach (var evt in m_PlayModeStateChangedEvent)
511+
{
512+
scope.SetText($"{evt.Method?.DeclaringType?.FullName}.{evt.Method?.Name}", true);
492513
evt(state);
514+
}
493515
}
494516

495517
[RequiredByNativeCode]

Editor/Mono/EditorAssemblies.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,15 @@ private static void ProcessInitializeOnLoadAttributes(Type[] types)
113113
sortedTypes = types.OrderBy(x => Array.IndexOf(m_topologicallySortedAssemblies, x.Assembly));
114114
}
115115

116+
using var scope = new ProgressScope("Process InitializeOnLoad Attributes", "", forceShow: true);
117+
116118
foreach (Type type in sortedTypes)
117119
{
118-
using (_profilerMarkerProcessInitializeOnLoadAttributes.Auto(reportTimes, () => type.AssemblyQualifiedName))
120+
using (_profilerMarkerProcessInitializeOnLoadAttributes.Auto(reportTimes,
121+
() => type.AssemblyQualifiedName))
119122
{
123+
var typeFullName = type?.FullName;
124+
scope.SetText($"{typeFullName}.{typeFullName}", true);
120125
try
121126
{
122127
RuntimeHelpers.RunClassConstructor(type.TypeHandle);
@@ -137,10 +142,13 @@ private static void ProcessInitializeOnLoadAttributes(Type[] types)
137142
private static void ProcessInitializeOnLoadMethodAttributes()
138143
{
139144
bool reportTimes = (bool)Debug.GetDiagnosticSwitch("EnableDomainReloadTimings").value;
145+
using var scope = new ProgressScope("Process InitializeOnLoadMethod Attributes", "", forceShow: true);
140146
foreach (var method in TypeCache.GetMethodsWithAttribute<InitializeOnLoadMethodAttribute>())
141147
{
142-
using (_profilerMarkerProcessInitializeOnLoadMethodAttributes.Auto(reportTimes, () => $"{method.DeclaringType?.FullName}::{method.Name}"))
148+
using (_profilerMarkerProcessInitializeOnLoadMethodAttributes.Auto(reportTimes,
149+
() => $"{method.DeclaringType?.FullName}::{method.Name}"))
143150
{
151+
scope.SetText($"${method.DeclaringType?.FullName}.{method?.Name}", true);
144152
try
145153
{
146154
method.Invoke(null, null);

Editor/Mono/GUI/TreeView/TreeViewController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ public void OnGUI(Rect rect, int keyboardControlID)
743743
KeyboardGUI();
744744

745745
if (m_UseScrollView)
746-
GUI.EndScrollView(showingVerticalScrollBar);
746+
GUI.EndScrollView(showingVerticalScrollBar || showingHorizontalScrollBar);
747747
else
748748
GUI.EndClip();
749749

0 commit comments

Comments
 (0)