Skip to content

Commit 9436b69

Browse files
author
Unity Technologies
committed
Unity 2023.1.0a23 C# reference source code
1 parent 016297e commit 9436b69

File tree

105 files changed

+3927
-1895
lines changed

Some content is hidden

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

105 files changed

+3927
-1895
lines changed

Editor/Mono/AssetStore/AssetStoreWindow.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ namespace UnityEditor
1313
[EditorWindowTitle(title = "Asset Store", icon = "Asset Store")]
1414
internal class AssetStoreWindow : EditorWindow
1515
{
16-
// Use this for initialization
17-
// Index at 1499 because "Package Manager" is 1500, pairing tools for user to get external content
18-
[MenuItem("Window/Asset Store", false, 1499)]
1916
public static AssetStoreWindow Init()
2017
{
2118
if (EditorPrefs.GetBool("AlwaysOpenAssetStoreInBrowser", false))
@@ -32,14 +29,21 @@ public static AssetStoreWindow Init()
3229
}
3330
}
3431

35-
private static void OpenAssetStoreInBrowser()
32+
[MenuItem("Window/Asset Store", false, 1497)]
33+
public static void OpenAssetStoreInBrowser()
3634
{
3735
string assetStoreUrl = UnityConnect.instance.GetConfigurationURL(CloudConfigUrl.CloudAssetStoreUrl);
38-
if (UnityEditor.Connect.UnityConnect.instance.loggedIn)
39-
UnityEditor.Connect.UnityConnect.instance.OpenAuthorizedURLInWebBrowser(assetStoreUrl);
36+
if (UnityConnect.instance.loggedIn)
37+
UnityConnect.instance.OpenAuthorizedURLInWebBrowser(assetStoreUrl);
4038
else Application.OpenURL(assetStoreUrl);
4139
}
4240

41+
[MenuItem("Window/My Assets", false, 1498)]
42+
public static void OpenMyAssetsInPackageManager()
43+
{
44+
PackageManagerWindow.SelectPackageAndFilterStatic(string.Empty, PackageManager.UI.Internal.PackageFilterTab.AssetStore);
45+
}
46+
4347
public void OnEnable()
4448
{
4549
this.antiAliasing = 4;

Editor/Mono/BuildPipeline/NamedBuildTarget.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ namespace UnityEditor.Build
4141
public static readonly NamedBuildTarget WebGL = new NamedBuildTarget("WebGL");
4242
public static readonly NamedBuildTarget WindowsStoreApps = new NamedBuildTarget("Windows Store Apps");
4343
public static readonly NamedBuildTarget PS4 = new NamedBuildTarget("PS4");
44+
public static readonly NamedBuildTarget PS5 = new NamedBuildTarget("PS5");
4445
public static readonly NamedBuildTarget XboxOne = new NamedBuildTarget("XboxOne");
4546
public static readonly NamedBuildTarget tvOS = new NamedBuildTarget("tvOS");
4647
public static readonly NamedBuildTarget NintendoSwitch = new NamedBuildTarget("Nintendo Switch");

Editor/Mono/CustomEditorAttributes.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,13 @@ static bool TryGatherRenderPipelineTypes([DisallowNull] Type type, [DisallowNull
212212
}
213213
}
214214

215+
#pragma warning disable CS0618
215216
if (inspectAttr is CustomEditorForRenderPipelineAttribute attr)
216217
{
217218
results = new[] { attr.renderPipelineType };
218219
return true;
219220
}
221+
#pragma warning restore CS0618
220222

221223
results = null;
222224
return true;

Editor/Mono/Inspector/AssemblyDefinitionImporterInspector.cs

Lines changed: 104 additions & 62 deletions
Large diffs are not rendered by default.

Editor/Mono/Inspector/Editor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ internal interface IToolModeOwner
306306
bool ModeSurvivesSelectionChange(int toolMode);
307307
}
308308

309+
[Obsolete(@"CustomEditorForRenderPipelineAttribute is deprecated. Use CustomEditor with SupportedOnCurrentPipeline instead. #from(2023.1)", false)]
309310
[AttributeUsage(AttributeTargets.Class)]
310311
public class CustomEditorForRenderPipelineAttribute : CustomEditor
311312
{

Editor/Mono/Inspector/PlayerSettingsEditor/PlayerSettingsEditor.cs

Lines changed: 66 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ class SettingsContent
195195
public static readonly GUIContent requireAEP = EditorGUIUtility.TrTextContent("Require ES3.1+AEP");
196196
public static readonly GUIContent require32 = EditorGUIUtility.TrTextContent("Require ES3.2");
197197
public static readonly GUIContent skinOnGPU = EditorGUIUtility.TrTextContent("GPU Skinning*", "Calculate mesh skinning and blend shapes on the GPU via shaders");
198+
public static readonly GUIContent[] meshDeformations = { EditorGUIUtility.TrTextContent("CPU"), EditorGUIUtility.TrTextContent("GPU"), EditorGUIUtility.TrTextContent("GPU (Batched)") };
198199
public static readonly GUIContent scriptingDefineSymbols = EditorGUIUtility.TrTextContent("Scripting Define Symbols", "Preprocessor defines passed to the C# script compiler.");
199200
public static readonly GUIContent additionalCompilerArguments = EditorGUIUtility.TrTextContent("Additional Compiler Arguments", "Additional arguments passed to the C# script compiler.");
200201
public static readonly GUIContent scriptingDefineSymbolsApply = EditorGUIUtility.TrTextContent("Apply");
@@ -258,28 +259,30 @@ class SettingsContent
258259
public static readonly GUIContent allowHDRDisplay = EditorGUIUtility.TrTextContent("Allow HDR Display Output*", "Checks if the display supports HDR and if it does, switches to HDR output at the start of the application.");
259260
public static readonly GUIContent hdrOutputRequireHDRRenderingWarning = EditorGUIUtility.TrTextContent("The active Render Pipeline does not have HDR enabled. Enable HDR in the Render Pipeline Asset to see the changes.");
260261

261-
public static string undoChangedBatchingString { get { return LocalizationDatabase.GetLocalizedString("Changed Batching Settings"); } }
262-
public static string undoChangedGraphicsAPIString { get { return LocalizationDatabase.GetLocalizedString("Changed Graphics API Settings"); } }
263-
public static string undoChangedScriptingDefineString { get { return LocalizationDatabase.GetLocalizedString("Changed Scripting Define Settings"); } }
264-
public static string undoChangedGraphicsJobsString { get { return LocalizationDatabase.GetLocalizedString("Changed Graphics Jobs Setting"); } }
265-
public static string undoChangedGraphicsJobModeString { get { return LocalizationDatabase.GetLocalizedString("Changed Graphics Job Mode Setting"); } }
266-
public static string changeColorSpaceString { get { return LocalizationDatabase.GetLocalizedString("Changing the color space may take a significant amount of time."); } }
267-
public static string undoChangedPlatformShaderChunkSizeString { get { return LocalizationDatabase.GetLocalizedString("Changed Shader Chunk Size Platform Setting"); } }
268-
public static string undoChangedPlatformShaderChunkCountString { get { return LocalizationDatabase.GetLocalizedString("Changed Shader Chunk Count Platform Setting"); } }
269-
public static string undoChangedDefaultShaderChunkSizeString { get { return LocalizationDatabase.GetLocalizedString("Changed Shader Chunk Size Default Setting"); } }
270-
public static string undoChangedDefaultShaderChunkCountString { get { return LocalizationDatabase.GetLocalizedString("Changed Shader Chunk Count Default Setting"); } }
262+
public static readonly string undoChangedBatchingString = L10n.Tr("Changed Batching Settings");
263+
public static readonly string undoChangedGraphicsAPIString = L10n.Tr("Changed Graphics API Settings");
264+
public static readonly string undoChangedScriptingDefineString = L10n.Tr("Changed Scripting Define Settings");
265+
public static readonly string undoChangedGraphicsJobsString = L10n.Tr("Changed Graphics Jobs Setting");
266+
public static readonly string undoChangedGraphicsJobModeString = L10n.Tr("Changed Graphics Job Mode Setting");
267+
public static readonly string changeColorSpaceString = L10n.Tr("Changing the color space may take a significant amount of time.");
268+
public static readonly string undoChangedPlatformShaderChunkSizeString = L10n.Tr("Changed Shader Chunk Size Platform Setting");
269+
public static readonly string undoChangedPlatformShaderChunkCountString = L10n.Tr("Changed Shader Chunk Count Platform Setting");
270+
public static readonly string undoChangedDefaultShaderChunkSizeString = L10n.Tr("Changed Shader Chunk Size Default Setting");
271+
public static readonly string undoChangedDefaultShaderChunkCountString = L10n.Tr("Changed Shader Chunk Count Default Setting");
271272
}
272273

273274
class RecompileReason
274275
{
275-
public static readonly string scriptingDefineSymbolsModified = "Scripting define symbols setting modified";
276-
public static readonly string suppressCommonWarningsModified = "Suppress common warnings setting modified";
277-
public static readonly string allowUnsafeCodeModified = "Allow 'unsafe' code setting modified";
278-
public static readonly string apiCompatibilityLevelModified = "API Compatibility level modified";
279-
public static readonly string editorAssembliesCompatibilityLevelModified = "Editor Assemblies Compatibility level modified";
280-
public static readonly string useDeterministicCompilationModified = "Use deterministic compilation modified";
281-
public static readonly string additionalCompilerArgumentsModified = "Additional compiler arguments modified";
282-
public static readonly string activeBuildTargetGroupModified = "Active build target group modified";
276+
public static readonly string scriptingDefineSymbolsModified = L10n.Tr("Scripting define symbols setting modified");
277+
public static readonly string suppressCommonWarningsModified = L10n.Tr("Suppress common warnings setting modified");
278+
public static readonly string allowUnsafeCodeModified = L10n.Tr("Allow 'unsafe' code setting modified");
279+
public static readonly string apiCompatibilityLevelModified = L10n.Tr("API Compatibility level modified");
280+
public static readonly string editorAssembliesCompatibilityLevelModified = L10n.Tr("Editor Assemblies Compatibility level modified");
281+
public static readonly string useDeterministicCompilationModified = L10n.Tr("Use deterministic compilation modified");
282+
public static readonly string additionalCompilerArgumentsModified = L10n.Tr("Additional compiler arguments modified");
283+
public static readonly string activeBuildTargetGroupModified = L10n.Tr("Active build target group modified");
284+
285+
public static readonly string presetChanged = L10n.Tr("Preset changed");
283286
}
284287

285288
PlayerSettingsSplashScreenEditor m_SplashScreenEditor;
@@ -306,6 +309,7 @@ PlayerSettingsIconsEditor iconsEditor
306309

307310
private static GraphicsJobMode[] m_GfxJobModeValues = new GraphicsJobMode[] { GraphicsJobMode.Native, GraphicsJobMode.Legacy };
308311
private static GUIContent[] m_GfxJobModeNames = new GUIContent[] { EditorGUIUtility.TrTextContent("Native"), EditorGUIUtility.TrTextContent("Legacy") };
312+
private static MeshDeformation[] m_MeshDeformations = { MeshDeformation.CPU, MeshDeformation.GPU, MeshDeformation.GPUBatched };
309313

310314
// Section and tab selection state
311315

@@ -423,6 +427,7 @@ PlayerSettingsIconsEditor iconsEditor
423427
SerializedProperty m_CaptureSingleScreen;
424428

425429
SerializedProperty m_SkinOnGPU;
430+
SerializedProperty m_MeshDeformation;
426431

427432
SerializedProperty m_EnableLoadStoreDebugMode;
428433

@@ -640,6 +645,7 @@ void OnEnable()
640645
m_VisibleInBackground = FindPropertyAssert("visibleInBackground");
641646
m_AllowFullscreenSwitch = FindPropertyAssert("allowFullscreenSwitch");
642647
m_SkinOnGPU = FindPropertyAssert("gpuSkinning");
648+
m_MeshDeformation = FindPropertyAssert("meshDeformation");
643649
m_ForceSingleInstance = FindPropertyAssert("forceSingleInstance");
644650
m_UseFlipModelSwapchain = FindPropertyAssert("useFlipModelSwapchain");
645651

@@ -927,6 +933,11 @@ public override void OnInspectorGUI()
927933

928934
if (hasPresetWindowClosed)
929935
{
936+
// We recompile after the window is closed just to make sure all the values are set/shown correctly.
937+
// There might be a smarter idea where you detect the values that have changed and only do it if it's required,
938+
// but the way the Preset window applies those changes as well as the way IMGUI works makes it difficult to track.
939+
SetReason(RecompileReason.presetChanged);
940+
930941
OnPresetSelectorClosed();
931942
}
932943
else if (HasReasonToCompile())
@@ -1997,11 +2008,43 @@ private void OtherSectionRenderingGUI(BuildPlatform platform, ISettingEditorExte
19972008
// GPU Skinning toggle (only show on relevant platforms)
19982009
if (!BuildTargetDiscovery.PlatformHasFlag(platform.defaultTarget, TargetAttributes.GPUSkinningNotSupported))
19992010
{
2000-
EditorGUI.BeginChangeCheck();
2001-
EditorGUILayout.PropertyField(m_SkinOnGPU, SettingsContent.skinOnGPU);
2002-
if (EditorGUI.EndChangeCheck())
2011+
/// Adding support to other platforms in progress...
2012+
bool platformSupportsBatching =
2013+
platform.namedBuildTarget == NamedBuildTarget.NintendoSwitch ||
2014+
platform.namedBuildTarget == NamedBuildTarget.PS5;
2015+
2016+
if (platformSupportsBatching)
2017+
{
2018+
MeshDeformation currentDeformation = (MeshDeformation)m_MeshDeformation.intValue;
2019+
2020+
EditorGUI.BeginChangeCheck();
2021+
MeshDeformation newDeformation = BuildEnumPopup(SettingsContent.skinOnGPU, currentDeformation, m_MeshDeformations, SettingsContent.meshDeformations);
2022+
if (EditorGUI.EndChangeCheck())
2023+
{
2024+
m_SkinOnGPU.boolValue = newDeformation != MeshDeformation.CPU;
2025+
m_MeshDeformation.intValue = (int)newDeformation;
2026+
serializedObject.ApplyModifiedProperties();
2027+
ShaderUtil.RecreateSkinnedMeshResources();
2028+
}
2029+
}
2030+
else
20032031
{
2004-
ShaderUtil.RecreateSkinnedMeshResources();
2032+
// Use the original checkbox UI but preserve underlying batching mode whenever possible.
2033+
// We need to do this because gpuSkinning/meshDeformation are properties which are shared between all platforms
2034+
// and if the user sets gpuSkinning mode to "enabled", we actually want to preserve "batchEnabled" if it was set for other platforms.
2035+
// Platforms that do not support batching but have meshDeformation == GPUBatched just silently use original non-batched code.
2036+
EditorGUI.BeginChangeCheck();
2037+
EditorGUILayout.PropertyField(m_SkinOnGPU, SettingsContent.skinOnGPU);
2038+
if (EditorGUI.EndChangeCheck())
2039+
{
2040+
// Preserve the value of m_MeshDeformation when possible.
2041+
if (!m_SkinOnGPU.boolValue)
2042+
m_MeshDeformation.intValue = (int)MeshDeformation.CPU;
2043+
else
2044+
m_MeshDeformation.intValue = m_MeshDeformation.intValue != (int)MeshDeformation.CPU ? m_MeshDeformation.intValue : (int)MeshDeformation.GPUBatched;
2045+
serializedObject.ApplyModifiedProperties();
2046+
ShaderUtil.RecreateSkinnedMeshResources();
2047+
}
20052048
}
20062049
}
20072050

@@ -2031,7 +2074,7 @@ private void OtherSectionRenderingGUI(BuildPlatform platform, ISettingEditorExte
20312074
PlayerSettings.SetGraphicsJobModeForPlatform(platform.defaultTarget, newGfxJobMode);
20322075
graphicsJobsModeOptionEnabled = false;
20332076
}
2034-
else if (platform.namedBuildTarget == new NamedBuildTarget("PS5"))
2077+
else if (platform.namedBuildTarget == NamedBuildTarget.PS5)
20352078
{
20362079
// On PS5NGGC, we only have kGfxJobModeNative so we disable the options in that case
20372080
GraphicsDeviceType[] gfxAPIs = PlayerSettings.GetGraphicsAPIs(platform.defaultTarget);

Editor/Mono/Inspector/TimeManagerInspector.cs

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Copyright (c) Unity Technologies. For terms of use, see
33
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
44

5+
using System;
6+
using Unity.IntegerTime;
57
using UnityEngine;
68

79
namespace UnityEditor
@@ -17,31 +19,60 @@ class Content
1719
public static readonly GUIContent maxParticleTimestepLabel = EditorGUIUtility.TrTextContent("Maximum Particle Timestep", "The maximum frame delta time Unity permits for a single iteration of the Particle System update. If the delta time is larger than this value, Unity will run the Particle System update multiple times during the frame with smaller timesteps. This preserves the quality of the simulation.");
1820
}
1921

20-
SerializedProperty m_FixedTimestepProperty;
22+
SerializedProperty m_FixedTimestepCountProperty;
2123
SerializedProperty m_MaxAllowedTimestepProperty;
2224
SerializedProperty m_TimeScaleProperty;
2325
SerializedProperty m_MaxParticleTimestepProperty;
2426

27+
static RationalTime.TicksPerSecond m_FixedTimeTicksPerSecond;
28+
const float MinFixedTimeStep = 0.0001f;
29+
2530
public void OnEnable()
2631
{
27-
m_FixedTimestepProperty = serializedObject.FindProperty("Fixed Timestep");
32+
var fixedTimestepProperty = serializedObject.FindProperty("Fixed Timestep");
33+
m_FixedTimestepCountProperty = fixedTimestepProperty.FindPropertyRelative("m_Count");
2834
m_MaxAllowedTimestepProperty = serializedObject.FindProperty("Maximum Allowed Timestep");
2935
m_TimeScaleProperty = serializedObject.FindProperty("m_TimeScale");
3036
m_MaxParticleTimestepProperty = serializedObject.FindProperty("Maximum Particle Timestep");
37+
38+
if (!m_FixedTimeTicksPerSecond.Valid) // FixedTime has a constant ticks per second value
39+
{
40+
var numerator = fixedTimestepProperty.FindPropertyRelative("m_Rate.m_Numerator");
41+
var denominator = fixedTimestepProperty.FindPropertyRelative("m_Rate.m_Denominator");
42+
m_FixedTimeTicksPerSecond =
43+
new RationalTime.TicksPerSecond(numerator.uintValue, denominator.uintValue);
44+
}
3145
}
3246

3347
public override void OnInspectorGUI()
3448
{
3549
serializedObject.Update();
3650

37-
EditorGUILayout.PropertyField(m_FixedTimestepProperty, Content.fixedTimestepLabel);
51+
DrawFixedTimeAsFloat(m_FixedTimestepCountProperty);
3852
EditorGUILayout.PropertyField(m_MaxAllowedTimestepProperty, Content.maxAllowedTimestepLabel);
3953
EditorGUILayout.PropertyField(m_TimeScaleProperty, Content.timeScaleLabel);
4054
EditorGUILayout.PropertyField(m_MaxParticleTimestepProperty, Content.maxParticleTimestepLabel);
4155

4256
serializedObject.ApplyModifiedProperties();
4357
}
4458

59+
static void DrawFixedTimeAsFloat(SerializedProperty prop)
60+
{
61+
var fixedTime = (float)new RationalTime(prop.longValue, m_FixedTimeTicksPerSecond).ToDouble(); // Convert a tick count to a float
62+
using (var c = new EditorGUI.ChangeCheckScope())
63+
{
64+
fixedTime = EditorGUILayout.FloatField(Content.fixedTimestepLabel, fixedTime);
65+
if (c.changed)
66+
{
67+
var newCount = RationalTime
68+
.FromDouble(MathF.Max(fixedTime, MinFixedTimeStep), m_FixedTimeTicksPerSecond)
69+
.Count; // convert it back to a count to store in the property
70+
prop.longValue = newCount;
71+
}
72+
}
73+
}
74+
75+
4576
[SettingsProvider]
4677
internal static SettingsProvider CreateProjectSettingsProvider()
4778
{

0 commit comments

Comments
 (0)