Skip to content

Commit e7d9de5

Browse files
author
Unity Technologies
committed
Unity 2023.2.0a20 C# reference source code
1 parent 18e481f commit e7d9de5

File tree

148 files changed

+9664
-9196
lines changed

Some content is hidden

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

148 files changed

+9664
-9196
lines changed

Editor/Mono/2D/SpriteAtlas/SpriteAtlasImporter.bindings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
namespace UnityEditor.U2D
1616
{
1717
// SpriteAtlas Importer lets you modify [[SpriteAtlas]]
18+
[HelpURL("https://docs.unity3d.com/2023.2/Documentation/Manual/SpriteAtlasV2.html")]
1819
[NativeHeader("Editor/Src/2D/SpriteAtlas/SpriteAtlasImporter.h")]
1920
public sealed partial class SpriteAtlasImporter : AssetImporter
2021
{

Editor/Mono/EditorGUI.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6376,7 +6376,7 @@ internal static bool HelpIconButton(Rect position, Object[] objs)
63766376
}
63776377
else
63786378
{
6379-
content.tooltip = string.Format("Open Reference for {0}.", helpTopic);
6379+
content.tooltip = string.Format("Open Reference for {0}.", ObjectNames.NicifyVariableName(helpTopic));
63806380
}
63816381
}
63826382

Editor/Mono/EditorMode/ModeService.cs

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ public struct ModeChangedArgs
9999
public int nextIndex;
100100
}
101101

102+
internal const string k_ModePathsCache = "mode-paths-cache";
102103
internal const string k_DefaultModeId = "default";
103104
internal const string k_ModeCurrentIdKeyName = "mode-current-id";
104105
internal const string k_MenuKeyChecked = "checked";
@@ -140,6 +141,7 @@ static ModeService()
140141

141142
modeChanged += OnModeChangeMenus;
142143
modeChanged += OnModeChangeLayouts;
144+
UnityEditor.PackageManager.Events.registeredPackages += OnRegisteredPackages;
143145

144146
ModeDescriptorImporter.allowExplicitModeRefresh = true;
145147
}
@@ -352,6 +354,12 @@ internal static bool HasStartupMode()
352354
return Application.HasARGV("editor-mode");
353355
}
354356

357+
private static void OnRegisteredPackages(PackageManager.PackageRegistrationEventArgs evt)
358+
{
359+
SessionState.EraseString(k_ModePathsCache);
360+
LoadModes();
361+
}
362+
355363
private static void LoadModes(bool checkStartupMode = false)
356364
{
357365
Log("LoadModes");
@@ -421,21 +429,38 @@ internal static void ScanModes()
421429
var builtinModeFile = Path.Combine(EditorApplication.applicationContentsPath, "Resources/default.mode");
422430
FillModeData(builtinModeFile, modesData);
423431

424-
var modeDescriptors = AssetDatabase.EnumerateAllAssets(new SearchFilter
432+
var modeFilePathCache = SessionState.GetString(k_ModePathsCache, "");
433+
434+
if (modeFilePathCache == "")
425435
{
426-
searchArea = SearchFilter.SearchArea.InPackagesOnly,
427-
classNames = new[] { nameof(ModeDescriptor) },
428-
showAllHits = true
429-
});
436+
var modeDescriptors = AssetDatabase.EnumerateAllAssets(new SearchFilter
437+
{
438+
searchArea = SearchFilter.SearchArea.InPackagesOnly,
439+
classNames = new[] { nameof(ModeDescriptor) },
440+
showAllHits = true
441+
});
430442

431-
while (modeDescriptors.MoveNext())
443+
while (modeDescriptors.MoveNext())
444+
{
445+
var md = modeDescriptors.Current.pptrValue as ModeDescriptor;
446+
if (md == null)
447+
continue;
448+
FillModeData(md.path, modesData);
449+
modeFilePathCache += md.path + ";";
450+
}
451+
SessionState.SetString(k_ModePathsCache, modeFilePathCache);
452+
}
453+
else
432454
{
433-
var md = modeDescriptors.Current.pptrValue as ModeDescriptor;
434-
if (md == null)
435-
continue;
436-
FillModeData(md.path, modesData);
455+
var paths = modeFilePathCache.Split(";");
456+
foreach(var path in paths)
457+
{
458+
if (!File.Exists(path))
459+
continue;
460+
FillModeData(path, modesData);
461+
}
437462
}
438-
463+
439464
modes = new ModeEntry[modesData.Keys.Count];
440465
modes[0] = CreateEntry(k_DefaultModeId, (JSONObject)modesData[k_DefaultModeId]);
441466
var modeIndex = 1;

Editor/Mono/EnumDataUtility.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,20 @@
44

55
using System;
66
using UnityEngine;
7+
using static UnityEngine.EnumDataUtility;
78

89
namespace UnityEditor
910
{
1011
internal static class EnumDataUtility
1112
{
1213
internal static EnumData GetCachedEnumData(Type enumType, bool excludeObsolete = true)
1314
{
14-
return UnityEngine.EnumDataUtility.GetCachedEnumData(enumType, excludeObsolete, ObjectNames.NicifyVariableName);
15+
return UnityEngine.EnumDataUtility.GetCachedEnumData(enumType, excludeObsolete ? CachedType.ExcludeObsolete : CachedType.IncludeObsoleteExceptErrors, ObjectNames.NicifyVariableName);
16+
}
17+
18+
internal static EnumData GetCachedEnumData(Type enumType, CachedType cachedType)
19+
{
20+
return UnityEngine.EnumDataUtility.GetCachedEnumData(enumType, cachedType, ObjectNames.NicifyVariableName);
1521
}
1622

1723
internal static int EnumFlagsToInt(EnumData enumData, Enum enumValue)

Editor/Mono/Inspector/LightingSettingsEditor.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -135,18 +135,6 @@ static class Styles
135135
public static readonly int[] lightmapMaxSizeValues = { 32, 64, 128, 256, 512, 1024, 2048, 4096 };
136136
public static readonly GUIContent[] lightmapMaxSizeStrings = Array.ConvertAll(lightmapMaxSizeValues, (x) => new GUIContent(x.ToString()));
137137

138-
// Keep in sync with GI/Progressive/LightmapTilingMode.h
139-
public static readonly int[] tiledBakingValues = { 0, 1, 2, 3, 4, -1 };
140-
public static readonly GUIContent[] tiledBakingStrings =
141-
{
142-
EditorGUIUtility.TrTextContent("Auto"),
143-
EditorGUIUtility.TrTextContent("4 Tiles"),
144-
EditorGUIUtility.TrTextContent("16 Tiles"),
145-
EditorGUIUtility.TrTextContent("64 Tiles"),
146-
EditorGUIUtility.TrTextContent("256 Tiles"),
147-
EditorGUIUtility.TrTextContent("Disabled"),
148-
};
149-
150138
// must match LightmapMixedBakeMode
151139
public static readonly int[] mixedModeValues = { 0, 1, 2 };
152140
public static readonly GUIContent[] mixedModeStrings =
@@ -222,7 +210,6 @@ static class Styles
222210
public static readonly GUIContent lightmapSizeFixed = EditorGUIUtility.TrTextContent("Fixed Lightmap Size", "Forces all lightmap textures to use the same size. These can be no larger than Max Lightmap Size.");
223211
public static readonly GUIContent useMipmapLimits = EditorGUIUtility.TrTextContent("Use Mipmap Limits", "Whether lightmap textures use the Global Mipmap limit defined in Quality Settings. Disable this to ensure lightmaps are available at the full mipmap resolution.");
224212
public static readonly GUIContent lightmapCompression = EditorGUIUtility.TrTextContent("Lightmap Compression", "Compresses baked lightmaps created using this Lighting Settings Asset. Lower quality compression reduces memory and storage requirements, at the cost of more visual artifacts. Higher quality compression requires more memory and storage, but provides better visual results.");
225-
public static readonly GUIContent tiledBaking = EditorGUIUtility.TrTextContent("Tiled baking", "Determines the tiled baking mode. Auto: Memory status triggers tiling. If Auto is not enabled, bakes may fail. Disabled: Never use tiling.");
226213
public static readonly GUIContent ambientOcclusion = EditorGUIUtility.TrTextContent("Ambient Occlusion", "Specifies whether to include ambient occlusion or not in the baked lightmap result. Enabling this results in simulating the soft shadows that occur in cracks and crevices of objects when light is reflected onto them.");
227214
public static readonly GUIContent ambientOcclusionContribution = EditorGUIUtility.TrTextContent("Indirect Contribution", "Adjusts the contrast of ambient occlusion applied to indirect lighting. The larger the value, the more contrast is applied to the ambient occlusion for indirect lighting.");
228215
public static readonly GUIContent ambientOcclusionContributionDirect = EditorGUIUtility.TrTextContent("Direct Contribution", "Adjusts the contrast of ambient occlusion applied to the direct lighting. The larger the value is, the more contrast is applied to the ambient occlusion for direct lighting. This effect is not physically accurate.");

Editor/Mono/Inspector/TextureInspector.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,10 @@ protected virtual void OnDisable()
237237
{
238238
RestoreLastTextureMipLevels();
239239

240+
m_TextureMipLevels.Clear();
241+
240242
m_CubemapPreview.OnDisable();
243+
m_Texture3DPreview.OnDisable();
241244
DestroyImmediate(m_Texture3DPreview);
242245
}
243246

Editor/Mono/Menu.bindings.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ public sealed class Menu
4242
[NativeMethod("MenuController::GetEnabled", true)]
4343
public static extern bool GetEnabled(string menuPath);
4444

45+
[NativeMethod("MenuController::UpdateContextMenu", true)]
46+
internal static extern void UpdateContextMenu(UnityEngine.Object[] context, int userData);
47+
4548
[NativeMethod("MenuController::GetEnabledWithContext", true)]
4649
internal static extern bool GetEnabledWithContext(string menuPath, UnityEngine.Object[] context);
4750

Editor/Mono/MenuUtility.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public static void AddMenuItemsForType<T>(DropdownMenu menu, IEnumerable<T> targ
5959
public static void AddMenuItemsForType(DropdownMenu menu, Type type, IEnumerable<Object> targets, string submenu = "")
6060
{
6161
var componentName = type.Name;
62+
Menu.UpdateContextMenu(ToArray(targets), 0);
6263
AddMenuItems(menu, componentName, Menu.GetMenuItems($"CONTEXT/{componentName}/", false, true), targets, submenu);
6364
}
6465

@@ -95,6 +96,8 @@ public static void AddComponentEntriesTo(DropdownMenu menu)
9596
if (type == typeof(GameObject) || type == typeof(Material))
9697
continue;
9798

99+
Menu.UpdateContextMenu(editor.targets, 0);
100+
98101
var items = Menu.GetMenuItems($"CONTEXT/{type.Name}/", false, true);
99102
if (items.Length == 0)
100103
continue;

Editor/Mono/PerformanceTools/FrameDebuggerData.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ internal class FrameDebuggerEventData
176176
public string m_RayTracingShaderPassName;
177177
public string m_RayTracingShaderRayGenShaderName;
178178
public string m_RayTracingShaderAccelerationStructureName;
179+
public int m_RayTracingShaderAccelerationStructureSize;
179180
public int m_RayTracingShaderMaxRecursionDepth;
180181
public int m_RayTracingShaderWidth;
181182
public int m_RayTracingShaderHeight;

Editor/Mono/PerformanceTools/FrameDebuggerEventDisplayData.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -766,16 +766,16 @@ private void BuildRayTracingEventDataStrings(FrameDebuggerEvent curEvent, FrameD
766766
bool hasAccelerationName = curEventData.m_RayTracingShaderAccelerationStructureName.Length > 0;
767767
string rayTracingMaxRecursionDepth = $"{curEventData.m_RayTracingShaderMaxRecursionDepth}";
768768
string rayTracingDispatchSize = $"{curEventData.m_RayTracingShaderWidth} x {curEventData.m_RayTracingShaderHeight} x {curEventData.m_RayTracingShaderDepth}";
769-
string rayTracingAccelerationStructure = hasAccelerationName ? curEventData.m_RayTracingShaderAccelerationStructureName : k_NotAvailableString;
769+
string rayTracingAccelerationStructure = hasAccelerationName ? $"{curEventData.m_RayTracingShaderAccelerationStructureName} ({curEventData.m_RayTracingShaderAccelerationStructureSize} KB)" : k_NotAvailableString;
770770
string rayTracingMissShaderCount = $"{curEventData.m_RayTracingShaderMissShaderCount}";
771771
string rayTracingCallableShaderCount = $"{curEventData.m_RayTracingShaderCallableShaderCount}";
772772
string rayTracingPassName = $"{curEventData.m_RayTracingShaderPassName}";
773773
m_RayTracingShaderName = $"{curEventData.m_RayTracingShaderName}";
774774
m_RayTracingGenerationShaderName = $"{curEventData.m_RayTracingShaderRayGenShaderName}";
775775

776-
m_DetailsStringBuilder.AppendFormat(k_TwoColumnFormat, "Max Recursion Depth", rayTracingMaxRecursionDepth).AppendLine();
776+
m_DetailsStringBuilder.AppendFormat(k_TwoColumnFormat, "Max. Recursion Depth", rayTracingMaxRecursionDepth).AppendLine();
777777
m_DetailsStringBuilder.AppendFormat(k_TwoColumnFormat, "Dispatch Size", rayTracingDispatchSize).AppendLine();
778-
m_DetailsStringBuilder.AppendFormat(k_TwoColumnFormat, "Acceleration Structure", rayTracingAccelerationStructure).AppendLine();
778+
m_DetailsStringBuilder.AppendFormat(k_TwoColumnFormat, "Accel. Structure", rayTracingAccelerationStructure).AppendLine();
779779
m_DetailsStringBuilder.AppendFormat(k_TwoColumnFormat, "Miss Shader Count", rayTracingMissShaderCount).AppendLine();
780780
m_DetailsStringBuilder.AppendFormat(k_TwoColumnFormat, "Callable Shader Count", rayTracingCallableShaderCount).AppendLine();
781781
m_DetailsStringBuilder.AppendLine();

0 commit comments

Comments
 (0)