Skip to content

Commit 94bcde1

Browse files
author
Unity Technologies
committed
Unity 2023.3.0a5 C# reference source code
1 parent 0aa4923 commit 94bcde1

File tree

69 files changed

+916
-361
lines changed

Some content is hidden

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

69 files changed

+916
-361
lines changed

Editor/Mono/BuildPipeline/NamedBuildTarget.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ namespace UnityEditor.Build
2727
"CloudRendering",
2828
"LinuxHeadlessSimulation",
2929
"Lumin",
30+
// This should have been "GameCoreXboxSeries"
3031
"GameCoreScarlett",
3132
"GameCoreXboxOne",
3233
"PS5",
@@ -41,6 +42,7 @@ namespace UnityEditor.Build
4142
public static readonly NamedBuildTarget Android = new NamedBuildTarget("Android");
4243
public static readonly NamedBuildTarget WebGL = new NamedBuildTarget("WebGL");
4344
public static readonly NamedBuildTarget WindowsStoreApps = new NamedBuildTarget("Windows Store Apps");
45+
// NDA platforms should not have been added here into the public API
4446
public static readonly NamedBuildTarget PS4 = new NamedBuildTarget("PS4");
4547
public static readonly NamedBuildTarget PS5 = new NamedBuildTarget("PS5");
4648
public static readonly NamedBuildTarget XboxOne = new NamedBuildTarget("XboxOne");

Editor/Mono/ImportSettings/DesktopPluginImporterExtension.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ internal override void OnGUI(PluginImporterInspector inspector)
153153
private readonly DesktopSingleCPUProperty m_LinuxManaged;
154154
private readonly DesktopSingleCPUProperty m_MacOSManaged;
155155

156+
private Property[] nativeProperties = null;
157+
private Property[] managedProperties = null;
158+
156159
public DesktopPluginImporterExtension()
157160
: base(null)
158161
{
@@ -169,12 +172,16 @@ public DesktopPluginImporterExtension()
169172
m_LinuxManaged = new DesktopSingleCPUProperty(EditorGUIUtility.TrTextContent("Linux x64"),BuildTarget.StandaloneLinux64);
170173
m_MacOSManaged = new DesktopSingleCPUProperty(EditorGUIUtility.TrTextContent("macOS 64-bit"),BuildTarget.StandaloneOSX);
171174

172-
properties = new Property[]
175+
nativeProperties = new Property[]
173176
{
174177
m_Windows32,
175178
m_Windows64,
176179
m_Linux,
177180
m_MacOS,
181+
};
182+
183+
managedProperties = new Property[]
184+
{
178185
m_Windows32Managed,
179186
m_Windows64Managed,
180187
m_LinuxManaged,
@@ -208,6 +215,11 @@ private bool IsUsableOnLinux(PluginImporter imp)
208215
return IsLinuxLibrary(imp.assetPath) || IsCppPluginFile(imp.assetPath);
209216
}
210217

218+
protected override Property[] GetPropertiesForInspector(PluginImporterInspector inspector)
219+
{
220+
return inspector.importer.isNativePlugin ? nativeProperties : managedProperties;
221+
}
222+
211223
public override void OnPlatformSettingsGUI(PluginImporterInspector inspector)
212224
{
213225
PluginImporter imp = inspector.importer;
@@ -257,7 +269,7 @@ public override void OnPlatformSettingsGUI(PluginImporterInspector inspector)
257269

258270
public void ValidateSingleCPUTargets(PluginImporterInspector inspector)
259271
{
260-
var singleCPUTargets = properties.OfType<DesktopSingleCPUProperty>();
272+
var singleCPUTargets = GetPropertiesForInspector(inspector).OfType<DesktopSingleCPUProperty>();
261273

262274
foreach (var target in singleCPUTargets)
263275
{

Editor/Mono/Inspector/AudioSourceInspector.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using UnityEngine;
66
using System.Collections.Generic;
77
using System.Linq;
8+
using UnityEngine.Audio;
89

910
namespace UnityEditor
1011
{
@@ -392,7 +393,17 @@ public override void OnInspectorGUI()
392393
EditorGUILayout.Space();
393394
EditorGUILayout.Slider(m_Volume, 0f, 1.0f, Styles.volumeLabel);
394395
EditorGUILayout.Space();
395-
EditorGUILayout.Slider(m_Pitch, -3.0f, 3.0f, Styles.pitchLabel);
396+
397+
var resource = m_AudioResource.objectReferenceValue as AudioResource;
398+
if (resource is AudioRandomContainer)
399+
{
400+
EditorGUILayout.Slider(m_Pitch, EPSILON, 3.0f, Styles.pitchLabel);
401+
402+
}
403+
else
404+
{
405+
EditorGUILayout.Slider(m_Pitch, -3.0f, 3.0f, Styles.pitchLabel);
406+
}
396407

397408
EditorGUILayout.Space();
398409

Editor/Mono/Inspector/LightProbeGroupInspector.cs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -717,21 +717,7 @@ public override void OnInspectorGUI()
717717

718718
if (srpHasAlternativeToLegacyProbes)
719719
{
720-
GUIStyle helpboxStyle = new GUIStyle(EditorStyles.helpBox)
721-
{
722-
wordWrap = true,
723-
alignment = TextAnchor.MiddleLeft,
724-
richText = true,
725-
padding = new RectOffset(36, 4, 4, 4)
726-
};
727-
728-
GUIContent content = new GUIContent(SupportedRenderingFeatures.active.overridesLightProbeSystemWarningMessage);
729-
float height = helpboxStyle.CalcHeight(content, EditorGUIUtility.currentViewWidth - helpboxStyle.padding.horizontal);
730-
731-
GUI.Box(GUILayoutUtility.GetRect(content, helpboxStyle, GUILayout.Height(height)), content, helpboxStyle);
732-
Rect r = GUILayoutUtility.GetLastRect();
733-
734-
GUI.Label(new Rect(r.x + 4, r.y + height / 2 - 16, 32, 32), EditorGUIUtility.IconContent("console.warnicon"));
720+
EditorGUILayout.HelpBox(SupportedRenderingFeatures.active.overridesLightProbeSystemWarningMessage, MessageType.Warning, true);
735721
}
736722
else
737723
{

Editor/Mono/Inspector/PlayerSettingsEditor/PlayerSettingsEditor.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2537,7 +2537,7 @@ private void OtherSectionIdentificationGUI(BuildPlatform platform, ISettingEdito
25372537
}
25382538
}
25392539

2540-
PlayerSettingsEditor.ShowBuildNumberUI(m_BuildNumber, BuildTargetGroup.Standalone, "Build", "'CFBundleVersion'");
2540+
PlayerSettingsEditor.ShowBuildNumberUI(m_BuildNumber, NamedBuildTarget.Standalone, "Build", "'CFBundleVersion'");
25412541

25422542
EditorGUILayout.PropertyField(m_MacAppStoreCategory, SettingsContent.macAppStoreCategory);
25432543
EditorGUILayout.PropertyField(m_UseMacAppStoreValidation, SettingsContent.useMacAppStoreValidation);
@@ -2647,13 +2647,11 @@ string GetSanitizedApplicationIdentifier()
26472647
}
26482648
}
26492649

2650-
internal static void ShowBuildNumberUI(SerializedProperty prop, BuildTargetGroup targetGroup, string label, string tooltip)
2650+
internal static void ShowBuildNumberUI(SerializedProperty prop, NamedBuildTarget buildTarget, string label, string tooltip)
26512651
{
2652-
var buildTargetGroup = BuildPipeline.GetBuildTargetGroupName(targetGroup);
2653-
26542652
if (!prop.serializedObject.isEditingMultipleObjects)
26552653
{
2656-
prop.TryGetMapEntry(buildTargetGroup, out var entry);
2654+
prop.TryGetMapEntry(buildTarget.TargetName, out var entry);
26572655

26582656
if (entry != null)
26592657
{

Editor/Mono/Inspector/TimeManagerInspector.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,14 @@ static void DrawFixedTimeAsFloat(SerializedProperty prop)
6161
var fixedTime = (float)new RationalTime(prop.longValue, m_FixedTimeTicksPerSecond).ToDouble(); // Convert a tick count to a float
6262
using (var c = new EditorGUI.ChangeCheckScope())
6363
{
64-
fixedTime = EditorGUILayout.FloatField(Content.fixedTimestepLabel, fixedTime);
64+
var maxFixedTime = MathF.Max(fixedTime, MinFixedTimeStep);
65+
var roundedTime = Math.Round(maxFixedTime, 4, MidpointRounding.AwayFromZero);
66+
fixedTime = EditorGUILayout.FloatField(Content.fixedTimestepLabel, (float)roundedTime);
67+
6568
if (c.changed)
6669
{
6770
var newCount = RationalTime
68-
.FromDouble(MathF.Max(fixedTime, MinFixedTimeStep), m_FixedTimeTicksPerSecond)
71+
.FromDouble(fixedTime, m_FixedTimeTicksPerSecond)
6972
.Count; // convert it back to a count to store in the property
7073
prop.longValue = newCount;
7174
}

Editor/Mono/InternalEditorUtility.bindings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ internal static bool RunningUnderWindows8(bool orHigher = true)
856856

857857
[StaticAccessor("UnityExtensions::Get()", StaticAccessorType.Dot)]
858858
[NativeMethod("IsCompatibleWithEditor")]
859-
extern internal static bool IsUnityExtensionCompatibleWithEditor(BuildTargetGroup targetGroup, BuildTarget target, string path);
859+
extern internal static bool IsUnityExtensionCompatibleWithEditor(BuildTarget target, string path);
860860

861861
[FreeFunction(IsThreadSafe = true)]
862862
extern public static bool CurrentThreadIsMainThread();

Editor/Mono/Modules/DefaultPluginImporterExtension.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ public DefaultPluginImporterExtension(Property[] properties)
8989
this.properties = properties;
9090
}
9191

92+
protected virtual Property[] GetPropertiesForInspector(PluginImporterInspector inspector)
93+
{
94+
return properties;
95+
}
96+
9297
public virtual void ResetValues(PluginImporterInspector inspector)
9398
{
9499
hasModified = false;
@@ -104,7 +109,7 @@ public virtual void Apply(PluginImporterInspector inspector)
104109
{
105110
if (!propertiesRefreshed) return;
106111

107-
foreach (var p in properties)
112+
foreach (var p in GetPropertiesForInspector(inspector))
108113
{
109114
p.Apply(inspector);
110115
}
@@ -126,7 +131,7 @@ public virtual void OnPlatformSettingsGUI(PluginImporterInspector inspector)
126131
if (!propertiesRefreshed) RefreshProperties(inspector);
127132

128133
EditorGUI.BeginChangeCheck();
129-
foreach (var p in properties)
134+
foreach (var p in GetPropertiesForInspector(inspector))
130135
{
131136
// skip CPU property for things that aren't native libs
132137
if (p.key == cpuKey && !inspector.importer.isNativePlugin)
@@ -138,7 +143,7 @@ public virtual void OnPlatformSettingsGUI(PluginImporterInspector inspector)
138143

139144
protected virtual void RefreshProperties(PluginImporterInspector inspector)
140145
{
141-
foreach (var p in properties)
146+
foreach (var p in GetPropertiesForInspector(inspector))
142147
{
143148
p.Reset(inspector);
144149
}

Editor/Mono/SerializedProperty.bindings.cs

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -270,21 +270,26 @@ public SerializedProperty GetArrayElementAtIndex(int index)
270270

271271
internal void SetToValueOfTarget(UnityObject target)
272272
{
273-
SerializedProperty targetProperty = new SerializedObject(target).FindProperty(propertyPath);
274-
if (targetProperty == null)
273+
using (SerializedObject targetObject = new SerializedObject(target))
275274
{
276-
Debug.LogError(target.name + " does not have the property " + propertyPath);
277-
return;
278-
}
275+
using (SerializedProperty targetProperty = targetObject.FindProperty(propertyPath))
276+
{
277+
if (targetProperty == null)
278+
{
279+
Debug.LogError(target.name + " does not have the property " + propertyPath);
280+
return;
281+
}
279282

280-
try
281-
{
282-
boxedValue = targetProperty.boxedValue;
283-
}
284-
catch (NotSupportedException ex)
285-
{
286-
// Previous implementation silently did nothing for unsupported types, now moving towards more strict error handling with this warning
287-
Debug.LogWarning(ex.Message);
283+
try
284+
{
285+
boxedValue = targetProperty.boxedValue;
286+
}
287+
catch (NotSupportedException ex)
288+
{
289+
// Previous implementation silently did nothing for unsupported types, now moving towards more strict error handling with this warning
290+
Debug.LogWarning(ex.Message);
291+
}
292+
}
288293
}
289294
}
290295

Editor/Mono/UIElements/EditorMenuExtensions.cs

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,21 @@ public enum DropdownMenuSearch
2020
Always
2121
}
2222

23+
public enum DropdownMenuLayout
24+
{
25+
Short,
26+
Medium,
27+
Long
28+
}
29+
2330
public class DropdownMenuDescriptor
2431
{
2532
public bool allowSubmenus { get; set; } = true;
2633
public bool autoClose { get; set; } = true;
2734
public bool expansion { get; set; } = true;
2835
public bool parseShortcuts { get; set; } = true;
2936
public DropdownMenuSearch search { get; set; } = DropdownMenuSearch.Auto;
37+
public DropdownMenuLayout layout { get; set; } = DropdownMenuLayout.Long;
3038
public string title { get; set; } = null;
3139
}
3240

@@ -49,7 +57,7 @@ public static class EditorMenuExtensions
4957
internal static readonly string searchCategoryUssClassName = GenericDropdownMenu.ussClassName + "__search-category";
5058
internal static readonly string shortcutUssClassName = GenericDropdownMenu.ussClassName + "__shortcut";
5159

52-
static float maxMenuHeight => Screen.currentResolution.height / (Screen.dpi / 96.0f) * 0.75f;
60+
static float maxMenuHeight => Screen.currentResolution.height / (Screen.dpi / 96.0f);
5361

5462
internal static bool isEditorContextMenuActive => s_ActiveMenus.Count > 0;
5563

@@ -102,7 +110,6 @@ void Host(GenericDropdownMenu menu)
102110
menu.customFocusHandling = true;
103111

104112
menu.innerContainer.style.maxWidth = k_MaxMenuWidth;
105-
menu.outerContainer.style.maxHeight = maxMenuHeight;
106113
menu.outerContainer.RegisterCallback<GeometryChangedEvent>(e =>
107114
{
108115
maxSize = minSize= menu.outerContainer.worldBound.size;
@@ -465,7 +472,7 @@ void ResetHighlighting(GenericDropdownMenu.MenuItem root)
465472
var menu = search.userData as GenericDropdownMenu;
466473
var newValue = Regex.Replace(e.newValue, "[^\\w ]+", "");
467474
search.SetValueWithoutNotify(newValue);
468-
475+
469476
ResetHighlighting(menu.root);
470477

471478
if (string.IsNullOrWhiteSpace(menu.current.name))
@@ -810,6 +817,23 @@ internal static void ApplyDescriptor(this GenericDropdownMenu menu, DropdownMenu
810817
if (desc.expansion)
811818
menu.MakeExpandable();
812819

820+
821+
var factor = 0f;
822+
switch (desc.layout)
823+
{
824+
case DropdownMenuLayout.Short:
825+
factor = 0.25f;
826+
break;
827+
case DropdownMenuLayout.Medium:
828+
factor = 0.5f;
829+
break;
830+
case DropdownMenuLayout.Long:
831+
default:
832+
factor = 0.75f;
833+
break;
834+
}
835+
menu.outerContainer.style.maxHeight = maxMenuHeight * factor;
836+
813837
menu.root.name = desc.title;
814838
menu.allowBackButton = !desc.expansion;
815839
menu.autoClose = desc.autoClose;

0 commit comments

Comments
 (0)