Skip to content

Commit 920f9d9

Browse files
author
Unity Technologies
committed
Unity 2021.2.0a12 C# reference source code
1 parent d873951 commit 920f9d9

File tree

86 files changed

+1918
-910
lines changed

Some content is hidden

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

86 files changed

+1918
-910
lines changed

Editor/IncrementalBuildPipeline/BeeBuildProgramCommon.Data/Data.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@ public class PackageInfo
1414
public class ConfigurationData
1515
{
1616
public string Il2CppDir;
17+
public string UnityLinkerPath;
18+
public string Il2CppPath;
1719
public string NetCoreRunPath;
1820
public string EditorContentsPath;
1921
public string ProjectDirectory;
2022
public PackageInfo[] Packages;
2123
public string UnityVersion;
2224
public string UnitySourceCodePath;
25+
public bool AdvancedLicense;
2326
}
2427
}

Editor/IncrementalBuildPipeline/PlayerBuildProgramLibrary.Data/Data.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ public class Plugin
88
{
99
public string AssetPath;
1010
public string DestinationPath;
11+
12+
public override string ToString()
13+
{
14+
return $"'{AssetPath} -> '{DestinationPath}'";
15+
}
1116
}
1217

1318
public class PluginsData
@@ -29,6 +34,7 @@ public class PlayerBuildConfig
2934
public bool InstallIntoBuildsFolder;
3035
public bool GenerateIdeProject;
3136
public bool Development;
37+
public Services Services;
3238
}
3339

3440
public class BuiltFilesOutput
@@ -49,7 +55,6 @@ public class LinkerConfig
4955
public string[] AdditionalArgs = new string[0];
5056
public bool AllowDebugging;
5157
public bool PerformEngineStripping;
52-
public string[] EngineStrippingFlags = new string[0];
5358
}
5459

5560
public class Il2CppConfig
@@ -66,4 +71,12 @@ public class Il2CppConfig
6671
public string ExtraTypes;
6772
public bool CreateSymbolFiles;
6873
}
74+
75+
public class Services
76+
{
77+
public bool EnableUnityConnect;
78+
public bool EnablePerformanceReporting;
79+
public bool EnableAnalytics;
80+
public bool EnableCrashReporting;
81+
}
6982
}

Editor/Mono/Animation/AnimationWindow/CurveEditor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,7 @@ public void CurveGUI()
11641164
DrawCurvesTangents();
11651165
DrawCurvesOverlay();
11661166

1167-
m_RectangleTool.OverlayOnGUI();
1167+
m_RectangleTool.OverlayOnGUI(rect);
11681168

11691169
EditSelectedPoints();
11701170
}

Editor/Mono/Animation/AnimationWindow/CurveEditorRectangleTool.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ public void OnGUI()
554554
GUI.color = oldColor;
555555
}
556556

557-
public void OverlayOnGUI()
557+
public void OverlayOnGUI(Rect bounds)
558558
{
559559
if (!hasSelection)
560560
return;
@@ -578,7 +578,7 @@ public void OverlayOnGUI()
578578
m_VBarTop.OnGUI(m_Layout.vBarTopRect);
579579
}
580580

581-
DrawLabels();
581+
DrawLabels(bounds);
582582

583583
GUI.color = oldColor;
584584
}
@@ -763,7 +763,7 @@ private ToolLayout CalculateLayout()
763763
return layout;
764764
}
765765

766-
private void DrawLabels()
766+
private void DrawLabels(Rect bounds)
767767
{
768768
if (dragMode == DragMode.None)
769769
return;
@@ -793,7 +793,6 @@ private void DrawLabels()
793793
{
794794
GUIContent labelContent = new GUIContent(string.Format("{0}", m_CurveEditor.FormatTime(selectionBounds.center.x, m_CurveEditor.invSnap, m_CurveEditor.timeFormat)));
795795
Vector2 labelSize = styles.dragLabel.CalcSize(labelContent);
796-
797796
EditorGUI.DoDropShadowLabel(new Rect(m_Layout.leftLabelAnchor.x, m_Layout.leftLabelAnchor.y, labelSize.x, labelSize.y), labelContent, styles.dragLabel, 0.3f);
798797
}
799798
}
@@ -831,7 +830,14 @@ private void DrawLabels()
831830
GUIContent labelContent = new GUIContent(string.Format("{0}, {1}", m_CurveEditor.FormatTime(localPosition.x, m_CurveEditor.invSnap, m_CurveEditor.timeFormat), m_CurveEditor.FormatValue(localPosition.y)));
832831
Vector2 labelSize = styles.dragLabel.CalcSize(labelContent);
833832

834-
EditorGUI.DoDropShadowLabel(new Rect(labelPosition.x, labelPosition.y - labelSize.y, labelSize.x, labelSize.y), labelContent, styles.dragLabel, 0.3f);
833+
// Clamp popup to remain inside the curve editor window
834+
var labelRect = new Rect(labelPosition.x, labelPosition.y - labelSize.y, labelSize.x, labelSize.y);
835+
labelRect.x += Mathf.Max(0.0f, bounds.xMin - labelRect.xMin);
836+
labelRect.x -= Mathf.Max(0.0f, labelRect.xMax - bounds.xMax);
837+
labelRect.y += Mathf.Max(0.0f, bounds.yMin - labelRect.yMin);
838+
labelRect.y -= Mathf.Max(0.0f, labelRect.yMax - bounds.yMax);
839+
840+
EditorGUI.DoDropShadowLabel(labelRect, labelContent, styles.dragLabel, 0.3f);
835841
}
836842
}
837843
}

Editor/Mono/BuildPipeline/AssemblyStripper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static string UnityLinkerPath
4747
{
4848
get
4949
{
50-
return Path.Combine(IL2CPPUtils.GetIl2CppFolder(), "build/deploy/netcoreapp3.1/UnityLinker" + (Application.platform == RuntimePlatform.WindowsEditor ? ".exe" : ""));
50+
return IL2CPPUtils.GetExePath("UnityLinker");
5151
}
5252
}
5353

Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -316,12 +316,6 @@ internal static void CopyMetadataFiles(string tempFolder, string destinationFold
316316
File.Copy(file, Paths.Combine(destinationFolder, Path.GetFileName(file)), true);
317317
}
318318

319-
internal static void CopyConfigFiles(string tempFolder, string destinationFolder)
320-
{
321-
var sourceFolder = Paths.Combine(IL2CPPBuilder.GetCppOutputDirectory(tempFolder), "Data", "etc");
322-
FileUtil.CopyDirectoryRecursive(sourceFolder, destinationFolder);
323-
}
324-
325319
internal static string ApiCompatibilityLevelToDotNetProfileArgument(ApiCompatibilityLevel compatibilityLevel)
326320
{
327321
switch (compatibilityLevel)
@@ -481,6 +475,19 @@ internal static string GetIl2CppFolder()
481475
"il2cpp"));
482476
}
483477

478+
internal static string GetIl2CppBeeSettingsFolder()
479+
{
480+
return $"{GetIl2CppFolder()}/build/BeeSettings/offline";
481+
}
482+
483+
internal static string GetExePath(string executableFileName)
484+
{
485+
var il2cppPath = $"{IL2CPPUtils.GetIl2CppFolder()}/build/deploy/net5.0/{executableFileName}{(Application.platform == RuntimePlatform.WindowsEditor ? ".exe" : "")}";
486+
if (!File.Exists(il2cppPath))
487+
il2cppPath = $"{IL2CPPUtils.GetIl2CppFolder()}/build/deploy/net5.0/{BinaryDirectoryForPlatform(Application.platform)}/{executableFileName}{(Application.platform == RuntimePlatform.WindowsEditor ? ".exe" : "")}";
488+
return il2cppPath;
489+
}
490+
484491
internal static string GetTundraFolder()
485492
{
486493
return $"{GetIl2CppFolder()}/external/bee/tundra";
@@ -512,6 +519,15 @@ internal static string GetAdditionalArguments()
512519

513520
return arguments.Aggregate(String.Empty, (current, arg) => current + arg + " ");
514521
}
522+
523+
private static string BinaryDirectoryForPlatform(RuntimePlatform platform)
524+
{
525+
if (platform == RuntimePlatform.WindowsEditor)
526+
return "win-x64";
527+
else if (platform == RuntimePlatform.LinuxEditor)
528+
return "linux-x64";
529+
return "osx-x64";
530+
}
515531
}
516532

517533
internal class IL2CPPBuilder
@@ -811,7 +827,7 @@ private string EscapeSpacesInPath(string path)
811827

812828
public static string GetIl2CppExe()
813829
{
814-
return $"{IL2CPPUtils.GetIl2CppFolder()}/build/deploy/netcoreapp3.1/il2cpp{(Application.platform == RuntimePlatform.WindowsEditor ? ".exe" : "")}";
830+
return IL2CPPUtils.GetExePath("il2cpp");
815831
}
816832

817833
private string GetIl2CppTundraExe()

Editor/Mono/BuildTargetConverter.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ internal static class BuildTargetConverter
4646
return RuntimePlatform.GameCoreXboxSeries;
4747
case BuildTarget.GameCoreXboxOne:
4848
return RuntimePlatform.GameCoreXboxOne;
49+
case BuildTarget.Stadia:
50+
return RuntimePlatform.Stadia;
4951
case BuildTarget.EmbeddedLinux:
5052
return RuntimePlatform.EmbeddedLinuxArm64;
5153
default:

Editor/Mono/BuildTargetDiscovery.bindings.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ public enum TargetAttributes
3939
UsesNativeHDR = (1 << 18),
4040
// removed: ProtectedGraphicsMem = (1 << 19),
4141
IsMTRenderingDisabledByDefault = (1 << 20),
42-
ConfigurableNormalMapEncoding = (1 << 21)
42+
ConfigurableNormalMapEncoding = (1 << 21),
43+
ConfigurableDefaultTextureCompressionFormat = (1 << 22)
4344
}
4445

4546
[StructLayout(LayoutKind.Sequential)]

Editor/Mono/ConsoleWindow.cs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ private static void UpdateLogStyleFixedHeights()
126126
StringBuilder m_CopyString;
127127
private int m_ActiveInstanceID = 0;
128128
bool m_DevBuild;
129+
int m_CallstackTextStart = 0;
129130

130131
Vector2 m_TextScroll = Vector2.zero;
131132

@@ -285,14 +286,8 @@ static internal void LoadIcons()
285286
[RequiredByNativeCode]
286287
public static void LogChanged()
287288
{
288-
if (ms_ConsoleWindow == null)
289+
if (!ms_ConsoleWindow)
289290
return;
290-
291-
ms_ConsoleWindow.DoLogChanged();
292-
}
293-
294-
public void DoLogChanged()
295-
{
296291
ms_ConsoleWindow.Repaint();
297292
}
298293

@@ -324,9 +319,6 @@ internal void OnDisable()
324319
{
325320
m_ConsoleAttachToPlayerState?.Dispose();
326321
m_ConsoleAttachToPlayerState = null;
327-
328-
if (ms_ConsoleWindow == this)
329-
ms_ConsoleWindow = null;
330322
}
331323

332324
private int RowHeight => (Constants.LogStyleLineCount > 1 ? Mathf.Max(32, (Constants.LogStyleLineCount * m_LineHeight)) : m_LineHeight) + m_BorderHeight;
@@ -432,6 +424,7 @@ void SetActiveEntry(LogEntry entry)
432424
if (entry != null)
433425
{
434426
m_ActiveText = entry.message;
427+
m_CallstackTextStart = entry.callstackTextStartUTF16;
435428
// ping object referred by the log entry
436429
if (m_ActiveInstanceID != entry.instanceID)
437430
{
@@ -442,6 +435,7 @@ void SetActiveEntry(LogEntry entry)
442435
}
443436
else
444437
{
438+
m_CallstackTextStart = 0;
445439
m_ActiveText = string.Empty;
446440
m_ActiveInstanceID = 0;
447441
m_ListView.row = -1;
@@ -747,7 +741,7 @@ internal void OnGUI()
747741
// Display active text (We want word wrapped text with a vertical scrollbar)
748742
m_TextScroll = GUILayout.BeginScrollView(m_TextScroll, Constants.Box);
749743

750-
string stackWithHyperlinks = StacktraceWithHyperlinks(m_ActiveText);
744+
string stackWithHyperlinks = StacktraceWithHyperlinks(m_ActiveText, m_CallstackTextStart);
751745
float height = Constants.MessageStyle.CalcHeight(GUIContent.Temp(stackWithHyperlinks), position.width);
752746
EditorGUILayout.SelectableLabel(stackWithHyperlinks, Constants.MessageStyle, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true), GUILayout.MinHeight(height + 10));
753747

@@ -762,6 +756,9 @@ internal void OnGUI()
762756
EditorGUIUtility.systemCopyBuffer = m_CopyString.ToString();
763757
e.Use();
764758
}
759+
760+
if (!ms_ConsoleWindow)
761+
ms_ConsoleWindow = this;
765762
}
766763

767764
private void SearchField(Event e)
@@ -808,10 +805,11 @@ private void SearchField(Event e)
808805
}
809806
}
810807

811-
internal static string StacktraceWithHyperlinks(string stacktraceText)
808+
internal static string StacktraceWithHyperlinks(string stacktraceText, int callstackTextStart)
812809
{
813810
StringBuilder textWithHyperlinks = new StringBuilder();
814-
var lines = stacktraceText.Split(new string[] {"\n"}, StringSplitOptions.None);
811+
textWithHyperlinks.Append(stacktraceText.Substring(0, callstackTextStart));
812+
var lines = stacktraceText.Substring(callstackTextStart).Split(new string[] { "\n" }, StringSplitOptions.None);
815813
for (int i = 0; i < lines.Length; ++i)
816814
{
817815
string textBeforeFilePath = ") (at ";

Editor/Mono/EditorGUI.cs

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
using VirtualTexturing = UnityEngine.Rendering.VirtualTexturing;
2323
using PreviewMaterialType = UnityEditor.EditorGUIUtility.PreviewType;
2424
using System.Linq;
25+
using System.Reflection;
2526
using Unity.Profiling;
2627

2728
namespace UnityEditor
@@ -820,9 +821,14 @@ static EventType GetEventTypeForControlAllowDisabledContextMenuPaste(Event evt,
820821
return EventType.Ignore;
821822
}
822823

824+
internal static string DoTextField(RecycledTextEditor editor, int id, Rect position, string text, GUIStyle style, string allowedletters, out bool changed, bool reset, bool multiline, bool passwordField)
825+
{
826+
return DoTextField(editor, id, position, text, style, allowedletters, out changed, reset, multiline, passwordField, null);
827+
}
828+
823829
// Should we select all text from the current field when the mouse goes up?
824830
// (We need to keep track of this to support both SwipeSelection & initial click selects all)
825-
internal static string DoTextField(RecycledTextEditor editor, int id, Rect position, string text, GUIStyle style, string allowedletters, out bool changed, bool reset, bool multiline, bool passwordField)
831+
internal static string DoTextField(RecycledTextEditor editor, int id, Rect position, string text, GUIStyle style, string allowedletters, out bool changed, bool reset, bool multiline, bool passwordField, GUIStyle cancelButtonStyle)
826832
{
827833
Event evt = Event.current;
828834

@@ -1236,7 +1242,10 @@ internal static string DoTextField(RecycledTextEditor editor, int id, Rect posit
12361242
}
12371243
}
12381244

1239-
EditorGUIUtility.AddCursorRect(position, MouseCursor.Text);
1245+
var cursorRect = position;
1246+
if (cancelButtonStyle != null && !String.IsNullOrEmpty(text))
1247+
cursorRect.width -= cancelButtonStyle.fixedWidth;
1248+
EditorGUIUtility.AddCursorRect(cursorRect, MouseCursor.Text);
12401249
}
12411250

12421251
if (!editor.IsEditingControl(id))
@@ -1697,6 +1706,13 @@ internal static string TextFieldInternal(int id, Rect position, string text, GUI
16971706
return text;
16981707
}
16991708

1709+
internal static string TextFieldInternal(int id, Rect position, string text, GUIStyle style, GUIStyle cancelButtonStyle)
1710+
{
1711+
bool dummy;
1712+
text = DoTextField(s_RecycledEditor, id, IndentedRect(position), text, style, null, out dummy, false, false, false, cancelButtonStyle);
1713+
return text;
1714+
}
1715+
17001716
internal static string TextFieldInternal(Rect position, string text, GUIStyle style)
17011717
{
17021718
int id = GUIUtility.GetControlID(s_TextFieldHash, FocusType.Keyboard, position);
@@ -1754,7 +1770,7 @@ internal static string ToolbarSearchField(int id, Rect position, string text, GU
17541770
s_RecycledEditor.text = text = "";
17551771
GUI.changed = true;
17561772
}
1757-
text = DoTextField(s_RecycledEditor, id, textRect, text, searchFieldStyle, null, out dummy, false, false, false);
1773+
text = DoTextField(s_RecycledEditor, id, textRect, text, searchFieldStyle, null, out dummy, false, false, false, cancelButtonStyle);
17581774
GUI.Button(buttonRect, GUIContent.none, cancelButtonStyle);
17591775

17601776
return text;
@@ -6988,7 +7004,22 @@ internal static bool DefaultPropertyField(Rect position, SerializedProperty prop
69887004
case SerializedPropertyType.Color:
69897005
{
69907006
BeginChangeCheck();
6991-
Color newColor = ColorField(position, label, property.colorValue);
7007+
bool showAlpha = true;
7008+
bool hdr = false;
7009+
7010+
var propertyFieldInfo = ScriptAttributeUtility.GetFieldInfoFromProperty(property, out var propertyType);
7011+
if (propertyFieldInfo != null)
7012+
{
7013+
var attributes = propertyFieldInfo.GetCustomAttributes<ColorUsageAttribute>(false).ToArray();
7014+
if (attributes.Length > 0)
7015+
{
7016+
var attribute = attributes[0];
7017+
showAlpha = attribute.showAlpha;
7018+
hdr = attribute.hdr;
7019+
}
7020+
}
7021+
7022+
Color newColor = ColorField(position, label, property.colorValue, true, showAlpha, hdr);
69927023
if (EndChangeCheck())
69937024
{
69947025
property.colorValue = newColor;

0 commit comments

Comments
 (0)