Skip to content

Commit dd0d959

Browse files
author
Unity Technologies
committed
Unity 2023.2.0a6 C# reference source code
1 parent 51ea2cc commit dd0d959

File tree

302 files changed

+5133
-2668
lines changed

Some content is hidden

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

302 files changed

+5133
-2668
lines changed

Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,54 @@ internal static string GetExePath(string toolName)
458458
return $"{deployDirectory}/{expectedToolExecutableName}";
459459
}
460460

461+
internal static string GetLibrarySearchPaths(string name, string tfm, string customRoot = null)
462+
{
463+
var il2CppFolder = GetIl2CppFolder(out var isDevelopmentLocation);
464+
var expectedToolExecutableName = $"{name}.dll";
465+
466+
if (isDevelopmentLocation)
467+
{
468+
// Locating the correct development build to use is a little tricky. Complications come from
469+
// 1) We don't know if the Debug or Release build is desired. To overcome this we will pick whichever was modified most recently
470+
471+
var topLevel = il2CppFolder;
472+
if (customRoot != null)
473+
topLevel = Path.Combine(topLevel, customRoot);
474+
475+
var toolBinDirectory = Path.Combine(topLevel, name, "bin").ToNPath();
476+
var candidates = toolBinDirectory.Files($"*{expectedToolExecutableName}", recurse: true)
477+
.Where(f => f.Parent.FileName == tfm)
478+
.OrderByDescending(f => f.GetLastWriteTimeUtc())
479+
.ToArray();
480+
481+
if (candidates.Length == 0)
482+
throw new InvalidOperationException($"{name} does not appear to be built in {il2CppFolder}");
483+
484+
return candidates[0].Parent.ToString();
485+
}
486+
487+
throw new ArgumentException($"Could not locate assembly for {name}");
488+
}
489+
490+
internal static string ConstructBeeLibrarySearchPath()
491+
{
492+
var projectBinDirs = new[]
493+
{
494+
GetLibrarySearchPaths("Unity.Options", "netstandard2.0", "repos/UnityOptions"),
495+
GetLibrarySearchPaths("Unity.Linker.Api", "netstandard2.0"),
496+
GetLibrarySearchPaths("Unity.IL2CPP.Api", "netstandard2.0"),
497+
GetLibrarySearchPaths("Unity.Api.Attributes", "netstandard2.0"),
498+
GetLibrarySearchPaths("Unity.IL2CPP.Bee.IL2CPPExeCompileCppBuildProgram.Data", "netstandard2.0"),
499+
GetLibrarySearchPaths("Unity.IL2CPP.Bee.BuildLogic", "net6.0"),
500+
// Now the quirky part. We need to locate the platform build logic assemblies.
501+
// While il2cpp will have these during some build scenarios (IDE build or build.pl)
502+
// the project that will always have all of the is il2cpp-compile
503+
GetExePath("il2cpp-compile").ToNPath().Parent
504+
};
505+
506+
return projectBinDirs.Aggregate(string.Empty, (accum, next) => $"{accum}{Path.PathSeparator}{next}");
507+
}
508+
461509
internal static string GetAdditionalArguments()
462510
{
463511
var arguments = new List<string>();

Editor/Mono/EditorGUI.cs

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6518,7 +6518,25 @@ internal static bool ProgressBar(Rect position, float value, GUIContent content,
65186518
// Make a help box with a message to the user.
65196519
public static void HelpBox(Rect position, string message, MessageType type)
65206520
{
6521-
GUI.Label(position, EditorGUIUtility.TempContent(message, EditorGUIUtility.GetHelpIcon(type)), EditorStyles.helpBox);
6521+
HelpBox(position, EditorGUIUtility.TempContent(message, EditorGUIUtility.GetHelpIcon(type)));
6522+
}
6523+
6524+
public static void HelpBox(Rect position, GUIContent content)
6525+
{
6526+
if (content.image != null)
6527+
{
6528+
var labelRect = position;
6529+
int iconSize = content.image.width + EditorStyles.helpBox.padding.right;
6530+
labelRect.x += iconSize;
6531+
labelRect.width -= iconSize;
6532+
6533+
GUI.Label(position, EditorGUIUtility.TempContent(content.image), EditorStyles.helpBox);
6534+
GUI.Label(labelRect, EditorGUIUtility.TempContent(content.text), EditorStyles.helpBoxLabel);
6535+
}
6536+
else
6537+
{
6538+
GUI.Label(position, content, EditorStyles.helpBox);
6539+
}
65226540
}
65236541

65246542
internal static bool LabelHasContent(GUIContent label)
@@ -10709,23 +10727,26 @@ internal static void LayerMaskField(SerializedProperty property, GUIContent labe
1070910727

1071010728
public static void HelpBox(string message, MessageType type)
1071110729
{
10712-
LabelField(GUIContent.none, EditorGUIUtility.TempContent(message, EditorGUIUtility.GetHelpIcon(type)), EditorStyles.helpBox);
10730+
HelpBox(EditorGUIUtility.TempContent(message, EditorGUIUtility.GetHelpIcon(type)), true);
1071310731
}
1071410732

1071510733
// Make a help box with a message to the user.
1071610734
public static void HelpBox(string message, MessageType type, bool wide)
1071710735
{
10718-
LabelField(wide ? GUIContent.none : EditorGUIUtility.blankContent,
10719-
EditorGUIUtility.TempContent(message, EditorGUIUtility.GetHelpIcon(type)),
10720-
EditorStyles.helpBox);
10736+
HelpBox(EditorGUIUtility.TempContent(message, EditorGUIUtility.GetHelpIcon(type)), wide);
1072110737
}
1072210738

1072310739
// Make a help box with a message to the user.
1072410740
public static void HelpBox(GUIContent content, bool wide = true)
1072510741
{
10726-
LabelField(wide ? GUIContent.none : EditorGUIUtility.blankContent,
10727-
content,
10728-
EditorStyles.helpBox);
10742+
BeginHorizontal();
10743+
PrefixLabel(wide ? GUIContent.none : EditorGUIUtility.blankContent, EditorStyles.helpBox);
10744+
Rect r = GUILayoutUtility.GetRect(content, EditorStyles.helpBox);
10745+
int oldIndent = EditorGUI.indentLevel;
10746+
EditorGUI.indentLevel = 0;
10747+
EditorGUI.HelpBox(r, content);
10748+
EditorGUI.indentLevel = oldIndent;
10749+
EndHorizontal();
1072910750
}
1073010751

1073110752
// Make a label in front of some control.

Editor/Mono/EditorMode/MenuService.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -403,11 +403,8 @@ private static Dictionary<string, MenuItemScriptCommand> CombineMenuItemsFromAtt
403403
menuItemsResult.Add(menuItem.name, menuItem);
404404
}
405405

406-
if (!Application.HasARGV("suppressDefaultMenuEntries"))
407-
{
408-
// We always add the default mode menus (if not present)
409-
AddMenuItemsFromMode(menuItemsResult, s_MenuItemsDefaultMode.Values);
410-
}
406+
// Always adding the default menu, which may be filtered later when using a custom mode file
407+
AddMenuItemsFromMode(menuItemsResult, s_MenuItemsDefaultMode.Values);
411408

412409
// If the menus depend on the .mode file, we also add the other modes menus because the mode file can reference them
413410
if (menusDependOnModeFile)

Editor/Mono/EditorSettings.bindings.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,9 @@ public static bool enableCookiesInLightmapper
254254
#pragma warning restore 618
255255
}
256256

257+
[StaticAccessor("GetEditorSettings()", StaticAccessorType.Dot)]
258+
internal static extern bool recalculateEnvironmentLighting { get; set; }
259+
257260
[Obsolete("Bake with the Progressive Lightmapper.The backend that uses Enlighten to bake is obsolete.", true)]
258261
[StaticAccessor("GetEditorSettings()", StaticAccessorType.Dot)]
259262
public static extern bool enableEnlightenBakedGI { get; set; }

Editor/Mono/GI/BuiltinSkyManager.bindings.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,5 @@ internal class BuiltinSkyManager
1212
{
1313
private BuiltinSkyManager() {}
1414
extern public static bool StaticIsDone();
15-
extern public static bool enabled { get; set; }
1615
}
1716
}

Editor/Mono/GUI/EditorStyles.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,9 @@ public sealed class EditorStyles
269269
public static GUIStyle helpBox { get { return s_Current.m_HelpBox; } }
270270
private GUIStyle m_HelpBox;
271271

272+
internal static GUIStyle helpBoxLabel { get { return s_Current.m_HelpBoxLabel; } }
273+
private GUIStyle m_HelpBoxLabel;
274+
272275
public static GUIStyle toolbarSearchField { get { return s_Current.m_ToolbarSearchField; } }
273276
private GUIStyle m_ToolbarSearchField;
274277

@@ -568,6 +571,20 @@ private void InitSharedStyles()
568571
active = { textColor = Color.grey},
569572
focused = { textColor = Color.grey }
570573
};
574+
575+
m_HelpBoxLabel = new GUIStyle(m_HelpBox)
576+
{
577+
name = "HelpBoxLabel",
578+
normal = { background = null },
579+
hover = { background = null },
580+
active = { background = null },
581+
focused = { background = null },
582+
583+
onNormal = { background = null },
584+
onHover = { background = null },
585+
onActive = { background = null },
586+
onFocused = { background = null }
587+
};
571588
}
572589

573590
internal GUIStyle GetStyle(string styleName)

Editor/Mono/GUI/TypeSelectionList.cs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
44

55
using UnityEngine;
6-
using UnityEditor;
7-
using UnityEditorInternal;
86
using System;
97
using System.Collections.Generic;
108
using Object = UnityEngine.Object;
@@ -19,12 +17,20 @@ class TypeSelectionList
1917
public TypeSelectionList(Object[] objects)
2018
{
2119
// Create dictionary of lists of objects indexed by their type.
22-
Dictionary<string, List<Object>> types = new Dictionary<string, List<Object>>();
20+
var types = new Dictionary<string, List<Object>>();
2321
foreach (Object o in objects)
2422
{
25-
string typeName = ObjectNames.GetTypeName(o);
26-
if (o is GameObject && EditorUtility.IsPersistent(o))
27-
typeName = "Prefab";
23+
var typeName = ObjectNames.GetTypeName(o) + "{0}";
24+
25+
if (EditorUtility.IsPersistent(o))
26+
{
27+
if (o is GameObject)
28+
typeName = "Prefab{0}";
29+
30+
var importerType = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(o))?.GetType();
31+
if (importerType is not null && importerType != typeof(AssetImporter))
32+
typeName = $"{typeName} ({importerType.Name})";
33+
}
2834

2935
if (!types.ContainsKey(typeName))
3036
types[typeName] = new List<Object>();
@@ -33,7 +39,7 @@ public TypeSelectionList(Object[] objects)
3339

3440
// Create and store a TypeSelection per type.
3541
m_TypeSelections = new List<TypeSelection>();
36-
foreach (KeyValuePair<string, List<Object>> kvp in types)
42+
foreach (var kvp in types)
3743
m_TypeSelections.Add(new TypeSelection(kvp.Key, kvp.Value.ToArray()));
3844

3945
// Sort the TypeSelections
@@ -50,7 +56,11 @@ public TypeSelection(string typeName, Object[] objects)
5056
{
5157
System.Diagnostics.Debug.Assert(objects != null && objects.Length >= 1);
5258
this.objects = objects;
53-
label = new GUIContent(objects.Length + " " + ObjectNames.NicifyVariableName(typeName) + (objects.Length > 1 ? "s" : ""));
59+
60+
label = new GUIContent(
61+
$"{objects.Length} " +
62+
$"{ObjectNames.NicifyVariableName(string.Format(typeName, objects.Length > 1 ? "s" : ""))}");
63+
5464
if (objects[0] is GameObject)
5565
label.image = EditorUtility.IsPersistent(objects[0]) ? PrefabUtility.GameObjectStyles.prefabIcon : PrefabUtility.GameObjectStyles.gameObjectIcon;
5666
else

Editor/Mono/Help.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,11 @@ internal static string GetHelpURLForObject(Object obj, bool defaultToMonoBehavio
211211
}
212212
}
213213

214-
return url;
214+
if (IsURL(url))
215+
return url;
216+
217+
// Assume url is a topic that needs to be properly formatted:
218+
return FindHelpNamed(url);
215219
}
216220

217221
var topicForObject = HelpFileNameForObject(obj);
@@ -429,6 +433,11 @@ private static void InitDocumentation()
429433
}
430434
}
431435

436+
private static bool IsURL(string path)
437+
{
438+
return path.StartsWith("http://") || path.StartsWith("https://") || path.StartsWith(k_AbsoluteFileRef);
439+
}
440+
432441
private static bool IsLocalPath(string path)
433442
{
434443
return !path.StartsWith("http://") && !path.StartsWith("https://");

Editor/Mono/Inspector/CanvasEditor.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ internal class CanvasEditor : Editor
2828
SerializedProperty m_OverrideSorting;
2929
SerializedProperty m_ShaderChannels;
3030
SerializedProperty m_UpdateRectTransformForStandalone;
31+
SerializedProperty m_VertexColorAlwaysGammaSpace;
3132

3233
AnimBool m_OverlayMode;
3334
AnimBool m_CameraMode;
@@ -47,6 +48,7 @@ private static class Styles
4748
public static GUIContent m_ShaderChannel = EditorGUIUtility.TrTextContent("Additional Shader Channels");
4849
public static GUIContent pixelPerfectContent = EditorGUIUtility.TrTextContent("Pixel Perfect");
4950
public static GUIContent standaloneRenderResize = EditorGUIUtility.TrTextContent("Resize Canvas", "For manual Camera.Render calls should the canvas resize to match the destination target.");
51+
public static GUIContent vertexColorAlwaysGammaSpace = EditorGUIUtility.TrTextContent("Vertex Color Always In Gamma Color Space", "UI vertex colors are always in gamma color space disregard of the player settings");
5052
}
5153

5254
private bool m_AllNested = false;
@@ -81,6 +83,7 @@ void OnEnable()
8183
m_PixelPerfectOverride = serializedObject.FindProperty("m_OverridePixelPerfect");
8284
m_ShaderChannels = serializedObject.FindProperty("m_AdditionalShaderChannelsFlag");
8385
m_UpdateRectTransformForStandalone = serializedObject.FindProperty("m_UpdateRectTransformForStandalone");
86+
m_VertexColorAlwaysGammaSpace = serializedObject.FindProperty("m_VertexColorAlwaysGammaSpace");
8487

8588
m_OverlayMode = new AnimBool(m_RenderMode.intValue == 0);
8689
m_OverlayMode.valueChanged.AddListener(Repaint);
@@ -317,6 +320,14 @@ public override void OnInspectorGUI()
317320
EditorGUI.HelpBox(rect, helpMessage, MessageType.Warning);
318321
}
319322
}
323+
324+
EditorGUILayout.PropertyField(m_VertexColorAlwaysGammaSpace, Styles.vertexColorAlwaysGammaSpace);
325+
326+
if (PlayerSettings.colorSpace == ColorSpace.Linear)
327+
{
328+
if (!m_VertexColorAlwaysGammaSpace.boolValue)
329+
EditorGUILayout.HelpBox( "Keep vertex color in Gamma space to allow gamma to linear color space conversion to happen in UI shaders. This will enhance UI color precision in linear color space.", MessageType.Warning);
330+
}
320331
}
321332
else
322333
{

Editor/Mono/Inspector/EditorSettingsInspector.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using UnityEditorInternal;
88
using UnityEngine;
99
using UnityEditor.Hardware;
10+
using UnityEngine.Rendering;
1011
using UnityEditor.Collaboration;
1112
using UnityEngine.Assertions;
1213

@@ -58,6 +59,7 @@ class Content
5859
public static GUIContent showLightmapResolutionOverlay = EditorGUIUtility.TrTextContent("Show Lightmap Resolution Overlay");
5960
public static GUIContent useLegacyProbeSampleCount = EditorGUIUtility.TrTextContent("Use legacy Light Probe sample counts", "Uses fixed Light Probe sample counts for baking with the Progressive Lightmapper. The sample counts are: 64 direct samples, 2048 indirect samples and 2048 environment samples.");
6061
public static GUIContent enableCookiesInLightmapper = EditorGUIUtility.TrTextContent("Enable baked cookies support", "Determines whether cookies should be evaluated by the Progressive Lightmapper during Global Illumination calculations. Introduced in version 2020.1. ");
62+
public static GUIContent recalculateEnvironmentLighting = EditorGUIUtility.TrTextContent("Recalculate Environment Lighting", "When enabled, Unity automatically calculates environment lighting using the SkyManager for all open scenes, if you haven't generated precomputed lighting data. This affects the ambient Light Probe and default cubemap which are both generated from the sky.");
6163

6264
public static GUIContent spritePacker = EditorGUIUtility.TrTextContent("Sprite Atlas");
6365
public static readonly GUIContent spriteMaxCacheSize = EditorGUIUtility.TrTextContent("Max SpriteAtlas Cache Size (GB)", "The size of the Sprite Atlas Cache folder will be kept below this maximum value when possible. Change requires Editor restart.");
@@ -260,6 +262,7 @@ public PopupElement(string id, string content)
260262
SerializedProperty m_PrefabModeAllowAutoSave;
261263
SerializedProperty m_UseLegacyProbeSampleCount;
262264
SerializedProperty m_DisableCookiesInLightmapper;
265+
SerializedProperty m_RecalculateEnvironmentLighting;
263266
SerializedProperty m_SpritePackerMode;
264267
SerializedProperty m_SpritePackerCacheSize;
265268
SerializedProperty m_Bc7TextureCompressor;
@@ -326,6 +329,9 @@ public void OnEnable()
326329
m_DisableCookiesInLightmapper = serializedObject.FindProperty("m_DisableCookiesInLightmapper");
327330
Assert.IsNotNull(m_DisableCookiesInLightmapper);
328331

332+
m_RecalculateEnvironmentLighting = serializedObject.FindProperty("m_RecalculateEnvironmentLighting");
333+
Assert.IsNotNull(m_RecalculateEnvironmentLighting);
334+
329335
m_SpritePackerMode = serializedObject.FindProperty("m_SpritePackerMode");
330336
Assert.IsNotNull(m_SpritePackerMode);
331337

@@ -573,6 +579,20 @@ public override void OnInspectorGUI()
573579
}
574580
EditorGUI.EndProperty();
575581

582+
// If either auto ambient or auto reflection baking is supported, show the SkyManager toggle.
583+
if (SupportedRenderingFeatures.active.autoAmbientProbeBaking || SupportedRenderingFeatures.active.autoDefaultReflectionProbeBaking)
584+
{
585+
EditorGUI.BeginChangeCheck();
586+
EditorGUILayout.PropertyField(m_RecalculateEnvironmentLighting, Content.recalculateEnvironmentLighting);
587+
if (EditorGUI.EndChangeCheck())
588+
{
589+
if (m_IsGlobalSettings)
590+
EditorSettings.recalculateEnvironmentLighting = m_RecalculateEnvironmentLighting.boolValue;
591+
592+
EditorApplication.RequestRepaintAllViews();
593+
}
594+
}
595+
576596
GUILayout.Space(10);
577597

578598
GUI.enabled = true;

0 commit comments

Comments
 (0)