Skip to content

Commit 2940f42

Browse files
author
Unity Technologies
committed
Unity 6000.1.0b2 C# reference source code
1 parent 72356ce commit 2940f42

File tree

73 files changed

+749
-733
lines changed

Some content is hidden

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

73 files changed

+749
-733
lines changed

Editor/Mono/Annotation/AnnotationWindow.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,16 @@ private enum EnabledState
5353
Mixed = 2
5454
}
5555

56-
const float kWindowWidth = 270;
57-
const float kLabelWidth = 150;
58-
const float scrollBarWidth = 14;
59-
const float listElementHeight = 18;
56+
const float k_WindowWidth = 270;
57+
const float k_ScrollBarWidth = 14;
58+
const float k_ListElementHeight = 18;
59+
const float k_JustClosedPeriod = 200;
60+
const float k_FrameWidth = 1f;
6061
float iconSize = 16;
6162
float gizmoRightAlign;
6263
float gizmoTextRightAlign;
6364
float iconRightAlign;
6465
float iconTextRightAlign;
65-
const float frameWidth = 1f;
6666

6767
static AnnotationWindow s_AnnotationWindow = null;
6868
static long s_LastClosedTime;
@@ -171,7 +171,7 @@ internal static bool ShowAtPosition(Rect buttonRect, bool isGameView)
171171
{
172172
// We could not use realtimeSinceStartUp since it is set to 0 when entering/exitting playmode, we assume an increasing time when comparing time.
173173
long nowMilliSeconds = System.DateTime.Now.Ticks / System.TimeSpan.TicksPerMillisecond;
174-
bool justClosed = nowMilliSeconds < s_LastClosedTime + 50;
174+
bool justClosed = nowMilliSeconds < s_LastClosedTime + k_JustClosedPeriod;
175175
if (!justClosed)
176176
{
177177
Event.current.Use();
@@ -205,9 +205,9 @@ void Init(Rect buttonRect, bool isGameView)
205205

206206
SyncToState();
207207

208-
float windowHeight = 2 * frameWidth + GetTopSectionHeight() + DrawNormalList(false, 100, 0, 10000);
208+
float windowHeight = 2 * k_FrameWidth + GetTopSectionHeight() + DrawNormalList(false, 100, 0, 10000);
209209
windowHeight = Mathf.Min(windowHeight, 900);
210-
Vector2 windowSize = new Vector2(kWindowWidth, windowHeight);
210+
Vector2 windowSize = new Vector2(k_WindowWidth, windowHeight);
211211

212212
ShowAsDropDown(buttonRect, windowSize);
213213
}
@@ -314,7 +314,7 @@ internal void OnGUI()
314314
void DrawTopSection(float topSectionHeight)
315315
{
316316
// Bg
317-
GUI.Label(new Rect(frameWidth, 0, position.width - 2 * frameWidth, topSectionHeight), "", EditorStyles.inspectorBig);
317+
GUI.Label(new Rect(k_FrameWidth, 0, position.width - 2 * k_FrameWidth, topSectionHeight), "", EditorStyles.inspectorBig);
318318

319319
float topmargin = 7;
320320
float margin = 11;
@@ -423,18 +423,18 @@ void DrawAnnotationList(float startY, float height)
423423
Rect scrollViewRect = new Rect(0,
424424
startY + barHeight,
425425
position.width - 4,
426-
height - barHeight - frameWidth);
426+
height - barHeight - k_FrameWidth);
427427
float totalContentHeight = DrawNormalList(false, 0, 0, 100000);
428428
Rect contentRect = new Rect(0, 0, 1, totalContentHeight);
429429
bool isScrollbarVisible = totalContentHeight > scrollViewRect.height;
430430
float listElementWidth = scrollViewRect.width;
431431
if (isScrollbarVisible)
432-
listElementWidth -= scrollBarWidth;
432+
listElementWidth -= k_ScrollBarWidth;
433433

434434
// Scrollview
435435
m_ScrollPosition = GUI.BeginScrollView(scrollViewRect, m_ScrollPosition, contentRect, false, false, GUI.skin.horizontalScrollbar, GUI.skin.verticalScrollbar, EditorStyles.scrollViewAlt);
436436
{
437-
DrawNormalList(true, listElementWidth, m_ScrollPosition.y - listElementHeight, m_ScrollPosition.y + totalContentHeight);
437+
DrawNormalList(true, listElementWidth, m_ScrollPosition.y - k_ListElementHeight, m_ScrollPosition.y + totalContentHeight);
438438
}
439439
GUI.EndScrollView();
440440
}
@@ -514,11 +514,11 @@ float DrawListSection(float y, string sectionHeader, List<GizmoInfo> listElement
514514
Flip(ref even);
515515
if (curY > startY && curY < endY)
516516
{
517-
Rect rect = new Rect(1, curY, listElementWidth - 2, listElementHeight);
517+
Rect rect = new Rect(1, curY, listElementWidth - 2, k_ListElementHeight);
518518
if (doDraw)
519519
DrawListElement(rect, even, listElements[i]);
520520
}
521-
curY += listElementHeight;
521+
curY += k_ListElementHeight;
522522
}
523523

524524
if (useSeperator)

Editor/Mono/Annotation/LayerVisibilityWindow.cs

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,13 @@ public Styles()
3535
}
3636
}
3737

38-
const float kScrollBarWidth = 14;
39-
const float kFrameWidth = 1f;
40-
const float kToggleSize = 17;
41-
const float kSeparatorHeight = 6;
42-
const string kLayerVisible = "Show/Hide Layer";
43-
const string kLayerPickable = "Toggle Pickable status this Layer. Non-Pickable items cannot be selected in the Scene View.";
38+
const float k_ScrollBarWidth = 14;
39+
const float k_FrameWidth = 1f;
40+
const float k_ToggleSize = 17;
41+
const float k_SeparatorHeight = 6;
42+
const float k_JustClosedPeriod = 200;
43+
const string k_LayerVisible = "Show/Hide Layer";
44+
const string k_LayerPickable = "Toggle Pickable status this Layer. Non-Pickable items cannot be selected in the Scene View.";
4445

4546
private static LayerVisibilityWindow s_LayerVisibilityWindow;
4647
private static long s_LastClosedTime;
@@ -86,7 +87,7 @@ internal static bool ShowAtPosition(Rect buttonRect)
8687
{
8788
// We could not use realtimeSinceStartUp since it is set to 0 when entering/exitting playmode, we assume an increasing time when comparing time.
8889
long nowMilliSeconds = System.DateTime.Now.Ticks / System.TimeSpan.TicksPerMillisecond;
89-
bool justClosed = nowMilliSeconds < s_LastClosedTime + 50;
90+
bool justClosed = nowMilliSeconds < s_LastClosedTime + k_JustClosedPeriod;
9091
if (!justClosed)
9192
{
9293
Event.current.Use();
@@ -107,16 +108,16 @@ private void Init(Rect buttonRect)
107108

108109
var rowCount = (s_LayerNames.Count + 2 + 1 + 1);
109110

110-
var windowHeight = rowCount * EditorGUI.kSingleLineHeight + kSeparatorHeight;
111+
var windowHeight = rowCount * EditorGUI.kSingleLineHeight + k_SeparatorHeight;
111112

112113
int sortingLayerCount = InternalEditorUtility.GetSortingLayerCount();
113114
if (sortingLayerCount > 1)
114115
{
115-
windowHeight += kSeparatorHeight + EditorGUI.kSingleLineHeight;
116+
windowHeight += k_SeparatorHeight + EditorGUI.kSingleLineHeight;
116117
windowHeight += sortingLayerCount * EditorGUI.kSingleLineHeight;
117118
}
118119
m_ContentHeight = windowHeight;
119-
windowHeight += 2 * kFrameWidth;
120+
windowHeight += 2 * k_FrameWidth;
120121
windowHeight = Mathf.Min(windowHeight, 600);
121122

122123
var windowSize = new Vector2(180, windowHeight);
@@ -132,12 +133,12 @@ internal void OnGUI()
132133
if (s_Styles == null)
133134
s_Styles = new Styles();
134135

135-
var scrollViewRect = new Rect(kFrameWidth, kFrameWidth, position.width - 2 * kFrameWidth, position.height - 2 * kFrameWidth);
136+
var scrollViewRect = new Rect(k_FrameWidth, k_FrameWidth, position.width - 2 * k_FrameWidth, position.height - 2 * k_FrameWidth);
136137
var contentRect = new Rect(0, 0, 1, m_ContentHeight);
137138
bool isScrollbarVisible = m_ContentHeight > scrollViewRect.height;
138139
float listElementWidth = scrollViewRect.width;
139140
if (isScrollbarVisible)
140-
listElementWidth -= kScrollBarWidth;
141+
listElementWidth -= k_ScrollBarWidth;
141142

142143
m_ScrollPosition = GUI.BeginScrollView(scrollViewRect, m_ScrollPosition, contentRect, false, false, GUI.skin.horizontalScrollbar, GUI.skin.verticalScrollbar, EditorStyles.scrollViewAlt);
143144
Draw(listElementWidth);
@@ -174,9 +175,9 @@ private void DrawHeader(ref Rect rect, string text, ref bool even)
174175

175176
private void DrawSeparator(ref Rect rect, bool even)
176177
{
177-
DrawListBackground(new Rect(rect.x + 1, rect.y, rect.width - 2, kSeparatorHeight), even);
178+
DrawListBackground(new Rect(rect.x + 1, rect.y, rect.width - 2, k_SeparatorHeight), even);
178179
GUI.Label(new Rect(rect.x + 5, rect.y + 3, rect.width - 10, 3), GUIContent.none, s_Styles.separator);
179-
rect.y += kSeparatorHeight;
180+
rect.y += k_SeparatorHeight;
180181
}
181182

182183
private void Draw(float listElementWidth)
@@ -279,16 +280,16 @@ private void DoLayerEntry(Rect rect, string layerName, bool even, bool showVisib
279280
EditorGUI.BeginChangeCheck();
280281
// text (works as visibility toggle as well)
281282
Rect textRect = rect;
282-
textRect.width -= kToggleSize * 2;
283+
textRect.width -= k_ToggleSize * 2;
283284
visible = GUI.Toggle(textRect, visible, EditorGUIUtility.TempContent(layerName), s_Styles.listTextStyle);
284285

285286
// visible checkbox
286-
var toggleRect = new Rect(rect.width - kToggleSize * 2, rect.y + (rect.height - kToggleSize) * 0.5f, kToggleSize, kToggleSize);
287+
var toggleRect = new Rect(rect.width - k_ToggleSize * 2, rect.y + (rect.height - k_ToggleSize) * 0.5f, k_ToggleSize, k_ToggleSize);
287288
visibleChanged = false;
288289
if (showVisible)
289290
{
290291
var iconRect = toggleRect;
291-
var gc = new GUIContent(string.Empty, visible ? s_Styles.visibleOn : s_Styles.visibleOff, kLayerVisible);
292+
var gc = new GUIContent(string.Empty, visible ? s_Styles.visibleOn : s_Styles.visibleOff, k_LayerVisible);
292293
GUI.Toggle(iconRect, visible, gc, GUIStyle.none);
293294
visibleChanged = EditorGUI.EndChangeCheck();
294295
}
@@ -297,9 +298,9 @@ private void DoLayerEntry(Rect rect, string layerName, bool even, bool showVisib
297298
lockedChanged = false;
298299
if (showLock)
299300
{
300-
toggleRect.x += kToggleSize;
301+
toggleRect.x += k_ToggleSize;
301302
EditorGUI.BeginChangeCheck();
302-
var gc = new GUIContent(string.Empty, picked ? s_Styles.notpickable : s_Styles.pickable, kLayerPickable);
303+
var gc = new GUIContent(string.Empty, picked ? s_Styles.notpickable : s_Styles.pickable, k_LayerPickable);
303304
GUI.Toggle(toggleRect, picked, gc, GUIStyle.none);
304305
lockedChanged = EditorGUI.EndChangeCheck();
305306
}

Editor/Mono/AssemblyInfo/AssemblyInfo.cs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,28 @@
3434
[assembly: InternalsVisibleTo("UnityEngine.Common")]
3535
[assembly: InternalsVisibleTo("Unity.PureCSharpTests")]
3636
[assembly: InternalsVisibleTo("Unity.IntegrationTests")]
37+
[assembly: InternalsVisibleTo("Unity.IntegrationTests.Android")]
38+
[assembly: InternalsVisibleTo("Unity.IntegrationTests.Animation")]
39+
[assembly: InternalsVisibleTo("Unity.IntegrationTests.AssetImporting")]
40+
[assembly: InternalsVisibleTo("Unity.IntegrationTests.BuildPipeline")]
41+
[assembly: InternalsVisibleTo("Unity.IntegrationTests.Builds")]
42+
[assembly: InternalsVisibleTo("Unity.IntegrationTests.CrashReporting")]
43+
[assembly: InternalsVisibleTo("Unity.IntegrationTests.DeploymentTargets")]
44+
[assembly: InternalsVisibleTo("Unity.IntegrationTests.EditorApplication")]
45+
[assembly: InternalsVisibleTo("Unity.IntegrationTests.EditorUI")]
46+
[assembly: InternalsVisibleTo("Unity.IntegrationTests.GameCore")]
47+
[assembly: InternalsVisibleTo("Unity.IntegrationTests.GameView")]
48+
[assembly: InternalsVisibleTo("Unity.IntegrationTests.Lightmapping")]
49+
[assembly: InternalsVisibleTo("Unity.IntegrationTests.Metro")]
50+
[assembly: InternalsVisibleTo("Unity.IntegrationTests.Misc")]
51+
[assembly: InternalsVisibleTo("Unity.IntegrationTests.PackageManager")]
52+
[assembly: InternalsVisibleTo("Unity.IntegrationTests.Profiler")]
53+
[assembly: InternalsVisibleTo("Unity.IntegrationTests.Rendering")]
54+
[assembly: InternalsVisibleTo("Unity.IntegrationTests.SceneVisibility")]
55+
[assembly: InternalsVisibleTo("Unity.IntegrationTests.ShortcutManager")]
56+
[assembly: InternalsVisibleTo("Unity.IntegrationTests.UIToolkit")]
57+
[assembly: InternalsVisibleTo("Unity.IntegrationTests.Framework.PackageManager")]
3758
[assembly: InternalsVisibleTo("Unity.DeploymentTests.Services")]
38-
[assembly: InternalsVisibleTo("Unity.IntegrationTests.ExternalVersionControl")]
39-
[assembly: InternalsVisibleTo("Unity.IntegrationTests.UnityAnalytics")]
4059
[assembly: InternalsVisibleTo("Unity.PerformanceIntegrationTests")]
4160
[assembly: InternalsVisibleTo("Unity.Timeline.Editor")]
4261
[assembly: InternalsVisibleTo("Unity.PackageManagerUI.Develop.Editor")]

Editor/Mono/AssetPipeline/SpeedTree/SpeedTreeImporterCommon.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ internal class Styles
8686
// Meshes labels
8787
public static GUIContent MeshesHeader = EditorGUIUtility.TrTextContent("Meshes");
8888
public static GUIContent UnitConversion = EditorGUIUtility.TrTextContent("Unit Conversion", "Select the unit conversion to apply to the imported SpeedTree asset.");
89-
public static GUIContent ScaleFactor = EditorGUIUtility.TrTextContent("Scale Factor", "How much to scale the tree model, interpreting the exported units as meters");
89+
public static GUIContent ScaleFactor = EditorGUIUtility.TrTextContent("Scale Factor", "How much to scale the tree model, interpreting the exported units as meters. Must be positive.");
9090
public static GUIContent[] UnitConversionNames =
9191
{
9292
new GUIContent("Leave As Is")
@@ -181,6 +181,14 @@ static internal void ShowMeshGUI(
181181
if (bShowCustomScaleFactor)
182182
{
183183
EditorGUILayout.PropertyField(scaleFactor, Styles.ScaleFactor);
184+
if (scaleFactor.floatValue < 0f)
185+
{
186+
scaleFactor.floatValue = 0f;
187+
}
188+
if (scaleFactor.floatValue == 0f)
189+
{
190+
EditorGUILayout.HelpBox("Scale factor must be positive.", MessageType.Warning);
191+
}
184192
}
185193
}
186194

Editor/Mono/BuildPipeline/DataBuildDirtyTracker.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,15 @@ class BuildData
5151
BuildOptions.ConnectWithProfiler |
5252
BuildOptions.UncompressedAssetBundle |
5353
BuildOptions.CompressWithLz4HC;
54+
55+
public string[] assemblyNames;
5456
}
5557

5658
private BuildData buildData;
5759
private string[] scenes;
5860
private NPath activeBuildProfilePath;
5961
public BuildOptions buildOptions;
62+
private string[] assemblyNames;
6063

6164
bool CheckAssetDirty(BuildDataInputFile file)
6265
{
@@ -106,6 +109,12 @@ bool DoCheckDirty()
106109
return true;
107110
}
108111

112+
if (!assemblyNames.SequenceEqual(buildData.assemblyNames))
113+
{
114+
Console.WriteLine("Rebuilding Data files because the assembly list is dirty");
115+
return true;
116+
}
117+
109118
if (buildData.inputFiles.Any(CheckAssetDirty))
110119
return true;
111120

@@ -148,7 +157,7 @@ bool DoCheckDirty()
148157
}
149158

150159
[RequiredByNativeCode]
151-
static public void WriteBuildData(string buildDataPath, BuildReport report, string[] scenes, string[] prefabs, string activeBuildProfilePath)
160+
static public void WriteBuildData(string buildDataPath, BuildReport report, string[] scenes, string[] prefabs, string activeBuildProfilePath, string[] assemblyNames)
152161
{
153162
var developmentBuild = report.summary.options.HasFlag(BuildOptions.Development);
154163
var inputScenes = new List<BuildDataInputFile>();
@@ -178,13 +187,14 @@ static public void WriteBuildData(string buildDataPath, BuildReport report, stri
178187
resourcePaths = ResourcesAPIInternal.GetAllPaths("").OrderBy(p => p).ToArray(),
179188
enabledModules = ModuleMetadata.GetModuleNames()
180189
.Where(m => ModuleMetadata.GetModuleIncludeSettingForModule(m) != ModuleIncludeSetting.ForceExclude)
181-
.ToArray()
190+
.ToArray(),
191+
assemblyNames = assemblyNames.OrderBy(p => p).ToArray()
182192
};
183193
buildDataPath.ToNPath().WriteAllText(JsonUtility.ToJson(buildData));
184194
}
185195

186196
[RequiredByNativeCode]
187-
static public bool CheckDirty(string buildDataPath, BuildOptions buildOptions, string[] scenes, string activeBuildProfilePath)
197+
static public bool CheckDirty(string buildDataPath, BuildOptions buildOptions, string[] scenes, string activeBuildProfilePath, string[] assemblyNames)
188198
{
189199
NPath buildReportPath = buildDataPath;
190200
if (!buildReportPath.FileExists())
@@ -197,7 +207,8 @@ static public bool CheckDirty(string buildDataPath, BuildOptions buildOptions, s
197207
buildData = JsonUtility.FromJson<BuildData>(buildReportPath.ReadAllText()),
198208
scenes = scenes,
199209
activeBuildProfilePath = activeBuildProfilePath,
200-
buildOptions = buildOptions
210+
buildOptions = buildOptions,
211+
assemblyNames = assemblyNames.OrderBy(p => p).ToArray()
201212
};
202213
return tracker.DoCheckDirty();
203214
}

Editor/Mono/BuildProfile/BuildProfile.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ void TryLoadQualitySettings()
344344

345345
void OnDisable()
346346
{
347-
if (BuildProfileContext.activeProfile == this)
347+
if (IsActiveBuildProfileOrPlatform())
348348
EditorUserBuildSettings.SetActiveProfileScriptingDefines(m_ScriptingDefines);
349349

350350
var playerSettingsDirty = EditorUtility.IsDirty(m_PlayerSettings);
@@ -371,6 +371,7 @@ static void ContextMenuReset(MenuCommand menuCommand)
371371

372372
targetBuildProfile.platformBuildProfile = null;
373373
targetBuildProfile.TryCreatePlatformSettings();
374+
targetBuildProfile.overrideGlobalScenes = false;
374375
targetBuildProfile.scenes = Array.Empty<EditorBuildSettingsScene>();
375376
targetBuildProfile.scriptingDefines = Array.Empty<string>();
376377

Editor/Mono/BuildProfile/BuildProfileContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ internal static BuildProfile activeProfile
106106

107107
EditorUserBuildSettings.activeBuildProfile = value;
108108

109-
activeProfileChanged?.Invoke(prev, value);
110109
OnActiveProfileChangedForSettingExtension(prev, value);
111110
value.UpdateGlobalManagerPlayerSettings();
111+
activeProfileChanged?.Invoke(prev, value);
112112
EditorGraphicsSettings.activeProfileHasGraphicsSettings = ActiveProfileHasGraphicsSettings();
113113
BuildProfileModuleUtil.RequestScriptCompilation(value);
114114
}

Editor/Mono/ConsoleWindow.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ internal class ConsoleWindow : EditorWindow, IHasCustomMenu
3030
private static int m_DefaultFontSize;
3131
private static List<MethodInfo> s_MethodsToHideInCallstack = null;
3232
private static Dictionary<MethodInfo, Regex> s_GenericMethodSignatureRegex = null;
33+
private static bool m_ShouldSkipClearingConsoleAfterBuild = false;
3334

3435
//TODO: move this out of here
3536
internal class Constants
@@ -1202,12 +1203,26 @@ private void AddStackTraceLoggingMenu(GenericMenu menu)
12021203

12031204
internal static void ClearConsoleOnRecompile()
12041205
{
1206+
//After building a player, there's a recompilation happening as well
1207+
//And in order not to lose the log entries, we need to skip clearing the console one time
1208+
if (BuildPipeline.isBuildingPlayer)
1209+
{
1210+
m_ShouldSkipClearingConsoleAfterBuild = true;
1211+
}
1212+
12051213
// During build process, there are multiple compilation events that can trigger console clearing
12061214
// We don't want to lose the log entries during build process so we re-enable the flag only when editor is not building
12071215
// For clearing on build we have a separate option
12081216
if (HasFlag(ConsoleFlags.ClearOnRecompile) && !BuildPipeline.isBuildingPlayer)
12091217
{
1210-
LogEntries.Clear();
1218+
if (!m_ShouldSkipClearingConsoleAfterBuild)
1219+
{
1220+
LogEntries.Clear();
1221+
}
1222+
else
1223+
{
1224+
m_ShouldSkipClearingConsoleAfterBuild = false;
1225+
}
12111226
}
12121227

12131228
}

0 commit comments

Comments
 (0)