Skip to content

Commit 243a8ca

Browse files
author
Unity Technologies
committed
Unity 2023.2.0a8 C# reference source code
1 parent cf05456 commit 243a8ca

File tree

181 files changed

+3585
-1606
lines changed

Some content is hidden

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

181 files changed

+3585
-1606
lines changed

Editor/Mono/BuildPlayerSceneTreeView.cs

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,44 @@ internal class BuildPlayerSceneTreeViewItem : TreeViewItem
1313
{
1414
private const string kAssetsFolder = "Assets/";
1515
private const string kSceneExtension = ".unity";
16-
1716
public static int kInvalidCounter = -1;
1817

18+
private string m_FullName;
19+
1920
public bool active;
2021
public int counter;
21-
public string fullName;
22-
public GUID guid;
23-
public void UpdateName()
22+
public string fullName
2423
{
25-
var name = AssetDatabase.GUIDToAssetPath(guid.ToString());
26-
if (name != fullName)
24+
get => m_FullName;
25+
set
2726
{
28-
fullName = name;
27+
if (m_FullName == value)
28+
return;
2929

30-
displayName = fullName;
30+
m_FullName = value;
31+
displayName = m_FullName;
3132
if (displayName.StartsWith(kAssetsFolder))
3233
displayName = displayName.Remove(0, kAssetsFolder.Length);
3334
var ext = displayName.LastIndexOf(kSceneExtension);
3435
if (ext > 0)
3536
displayName = displayName.Substring(0, ext);
3637
}
3738
}
39+
public GUID guid;
40+
41+
public void UpdateName()
42+
{
43+
var name = AssetDatabase.GUIDToAssetPath(guid.ToString());
44+
if (!string.IsNullOrEmpty(name) && name != fullName)
45+
fullName = name;
46+
}
3847

39-
public BuildPlayerSceneTreeViewItem(int id, int depth, GUID g, bool state) : base(id, depth)
48+
public BuildPlayerSceneTreeViewItem(EditorBuildSettingsScene scene) : base(scene.guid.GetHashCode(), 0)
4049
{
41-
active = state;
50+
active = scene.enabled;
4251
counter = kInvalidCounter;
43-
guid = g;
44-
fullName = "";
52+
guid = scene.guid;
53+
fullName = scene.path;
4554
UpdateName();
4655
}
4756
}
@@ -71,7 +80,7 @@ protected override TreeViewItem BuildRoot()
7180
List<EditorBuildSettingsScene> scenes = new List<EditorBuildSettingsScene>(EditorBuildSettings.scenes);
7281
foreach (var sc in scenes)
7382
{
74-
var item = new BuildPlayerSceneTreeViewItem(sc.guid.GetHashCode(), 0, sc.guid, sc.enabled);
83+
var item = new BuildPlayerSceneTreeViewItem(sc);
7584
root.AddChild(item);
7685
}
7786
return root;
@@ -314,6 +323,11 @@ public EditorBuildSettingsScene[] GetSceneList()
314323
{
315324
var sceneItem = rootItem.children[index] as BuildPlayerSceneTreeViewItem;
316325
sceneList[index] = new EditorBuildSettingsScene(sceneItem.fullName, sceneItem.active);
326+
327+
// If the scene was deleted AssetPathToGUID may not work and the guid will be lost
328+
// In that case restore it to the previous value
329+
if (sceneList[index].guid.Empty() && !sceneItem.guid.Empty())
330+
sceneList[index].guid = sceneItem.guid;
317331
}
318332
return sceneList;
319333
}

Editor/Mono/BuildPlayerWindowBuildMethods.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ internal static BuildPlayerOptions GetBuildPlayerOptionsInternal(bool askForBuil
313313
EditorBuildSettingsScene[] editorScenes = EditorBuildSettings.scenes;
314314
foreach (EditorBuildSettingsScene scene in editorScenes)
315315
{
316-
if (scene.enabled)
316+
if (scene.enabled && !string.IsNullOrEmpty(scene.path))
317317
scenesList.Add(scene.path);
318318
}
319319

Editor/Mono/EditorBuildSettings.bindings.cs

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public EditorBuildSettingsScene(GUID guid, bool enabled)
4545
public GUID guid { get { return m_guid; } set { m_guid = value; } }
4646
public static string[] GetActiveSceneList(EditorBuildSettingsScene[] scenes)
4747
{
48-
return scenes.Where(scene => scene.enabled).Select(scene => scene.path).ToArray();
48+
return scenes.Where(scene => scene.enabled && !string.IsNullOrEmpty(scene.path)).Select(scene => scene.path).ToArray();
4949
}
5050

5151
public int CompareTo(object obj)
@@ -74,27 +74,10 @@ private static void SceneListChanged()
7474

7575
public static EditorBuildSettingsScene[] scenes
7676
{
77-
get
78-
{
79-
var result = GetEditorBuildSettingsScenes();
80-
foreach (var scene in result)
81-
{
82-
if (scene.guid.Empty())
83-
{
84-
scene.guid = new GUID(AssetDatabase.AssetPathToGUID(scene.path));
85-
}
86-
else
87-
{
88-
scene.path = AssetDatabase.GUIDToAssetPath(scene.guid.ToString());
89-
}
90-
}
91-
return result;
92-
}
93-
set
94-
{
95-
SetEditorBuildSettingsScenes(value);
96-
}
77+
get => GetEditorBuildSettingsScenes();
78+
set => SetEditorBuildSettingsScenes(value);
9779
}
80+
9881
static extern EditorBuildSettingsScene[] GetEditorBuildSettingsScenes();
9982
static extern void SetEditorBuildSettingsScenes(EditorBuildSettingsScene[] scenes);
10083

Editor/Mono/EditorTextSettings.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ namespace UnityEditor
1919
internal class EditorTextSettings : TextSettings
2020
{
2121
private static EditorTextSettings s_DefaultTextSettings;
22+
private static float s_CurrentEditorSharpness;
2223

2324
const string k_DefaultEmojisFallback = "UIPackageResources/FontAssets/Emojis/";
2425
const string k_Platform =
@@ -27,8 +28,21 @@ internal class EditorTextSettings : TextSettings
2728
static EditorTextSettings()
2829
{
2930
IMGUITextHandle.GetEditorTextSettings = () => defaultTextSettings;
30-
IMGUITextHandle.GetEditorTextSharpness = (string fontAssetName) => EditorPrefs.GetFloat($"EditorTextSharpness_{fontAssetName}", 0.0f);
31-
IMGUITextHandle.GetEditorFont = () => EditorResources.GetFont(FontDef.Style.Normal);
31+
}
32+
33+
internal static void SetCurrentEditorSharpness(float sharpness)
34+
{
35+
s_CurrentEditorSharpness = sharpness;
36+
}
37+
38+
internal override float GetEditorTextSharpness()
39+
{
40+
return s_CurrentEditorSharpness;
41+
}
42+
43+
internal override Font GetEditorFont()
44+
{
45+
return EditorResources.GetFont(FontDef.Style.Normal);
3246
}
3347

3448
internal static EditorTextSettings defaultTextSettings

Editor/Mono/EditorUserBuildSettings.bindings.cs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,23 @@ public enum QNXOsVersion
331331
}
332332

333333
[NativeType(Header = "Editor/Src/EditorUserBuildSettings.h")]
334+
public enum EmbeddedArchitecture
335+
{
336+
[UnityEngine.InspectorName("Arm64")]
337+
Arm64 = 0,
338+
339+
[UnityEngine.InspectorName("Arm32")]
340+
Arm32 = 1,
341+
342+
[UnityEngine.InspectorName("X64")]
343+
X64 = 2,
344+
345+
[UnityEngine.InspectorName("X86")]
346+
X86 = 3,
347+
}
348+
349+
[NativeType(Header = "Editor/Src/EditorUserBuildSettings.h")]
350+
[Obsolete("QNXArchitecture is deprecated. Use EmbeddedArchitecture. (UnityUpgradeable) -> EmbeddedArchitecture")]
334351
public enum QNXArchitecture
335352
{
336353
[UnityEngine.InspectorName("Arm64")]
@@ -347,6 +364,7 @@ public enum QNXArchitecture
347364
}
348365

349366
[NativeType(Header = "Editor/Src/EditorUserBuildSettings.h")]
367+
[Obsolete("EmbeddedLinuxArchitecture is deprecated. Use EmbeddedArchitecture. (UnityUpgradeable) -> EmbeddedArchitecture")]
350368
public enum EmbeddedLinuxArchitecture
351369
{
352370
[UnityEngine.InspectorName("Arm64")]
@@ -396,7 +414,7 @@ public static extern QNXOsVersion selectedQnxOsVersion
396414
}
397415

398416
// QNX Architecture
399-
public static extern QNXArchitecture selectedQnxArchitecture
417+
public static extern EmbeddedArchitecture selectedQnxArchitecture
400418
{
401419
[NativeMethod("GetSelectedQNXArchitecture")]
402420
get;
@@ -405,15 +423,15 @@ public static extern QNXArchitecture selectedQnxArchitecture
405423
}
406424

407425
// Embedded Linux Architecture
408-
public static extern EmbeddedLinuxArchitecture selectedEmbeddedLinuxArchitecture
426+
public static extern EmbeddedArchitecture selectedEmbeddedLinuxArchitecture
409427
{
410428
[NativeMethod("GetSelectedEmbeddedLinuxArchitecture")]
411429
get;
412430
[NativeMethod("SetSelectedEmbeddedLinuxArchitecture")]
413431
set;
414432
}
415433

416-
// Embedded Linux remote device information
434+
// Embedded Linux && QNX remote device information
417435
public static extern bool remoteDeviceInfo { get; set; }
418436
public static extern string remoteDeviceAddress { get; set; }
419437
public static extern string remoteDeviceUsername { get; set; }

Editor/Mono/EventWithPerformanceTracker.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ public Invoker UpdateAndInvoke(T value)
422422
return new Invoker(ref m_Delegates);
423423
}
424424

425-
internal readonly ref struct Invoker
425+
internal readonly struct Invoker
426426
{
427427
private readonly EventWithPerformanceTracker.Entry m_Delegates;
428428
public Enumerator GetEnumerator() => new Enumerator(in this);

Editor/Mono/GUI/TreeView/GameObjectTreeViewGUI.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,6 @@ override protected void DoItemGUI(Rect rect, int row, TreeViewItem item, bool se
413413
if (goItem == null)
414414
return;
415415

416-
EnsureLazyInitialization(goItem);
417-
418416
if (goItem.isSceneHeader)
419417
{
420418
useBoldFont = (goItem.scene == SceneManager.GetActiveScene());
@@ -686,6 +684,8 @@ protected override void OnContentGUI(Rect rect, int row, TreeViewItem item, stri
686684
if (goItem == null)
687685
return;
688686

687+
EnsureLazyInitialization(goItem);
688+
689689
rect.xMax = m_ContentRectRight;
690690

691691
if (goItem.isSceneHeader)

Editor/Mono/GameView/GameViewSizes.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -264,13 +264,7 @@ private void InitBuiltinGroups()
264264

265265
internal static bool DefaultLowResolutionSettingForStandalone()
266266
{
267-
switch (EditorUserBuildSettings.activeBuildTarget)
268-
{
269-
case BuildTarget.StandaloneOSX:
270-
return !PlayerSettings.macRetinaSupport; // if retina support enabled -> expecting LowRes setting disabled by default
271-
default:
272-
return GUIUtility.pixelsPerPoint <= 1.0f;
273-
}
267+
return GUIUtility.pixelsPerPoint <= 1.0f;
274268
}
275269

276270
internal static bool DefaultLowResolutionSettingForSizeGroupType(GameViewSizeGroupType sizeGroupType)

Editor/Mono/Inspector/MonoScriptInspector.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,11 +276,11 @@ public override void OnInspectorGUI()
276276

277277
if (assemblyDefinitionFile != null)
278278
{
279-
var assemblyDefintionFileAsset = AssetDatabase.LoadAssetAtPath<TextAsset>(assemblyDefinitionFile);
279+
var assemblyDefinitionFileAsset = AssetDatabase.LoadAssetAtPath<TextAsset>(assemblyDefinitionFile);
280280

281281
using (new EditorGUI.DisabledScope(true))
282282
{
283-
EditorGUILayout.ObjectField("Definition File", assemblyDefintionFileAsset, typeof(TextAsset), false);
283+
EditorGUILayout.ObjectField("Definition File", assemblyDefinitionFileAsset, typeof(TextAsset), false);
284284
}
285285
}
286286

Editor/Mono/Inspector/PlayerSettingsEditor/PlayerSettingsEditor.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ class SettingsContent
9494
public static readonly GUIContent platformShaderChunkCount = EditorGUIUtility.TrTextContent("Chunk count", "Use this setting to control how much memory is used when loading shader variants.");
9595

9696
public static readonly GUIContent bakeCollisionMeshes = EditorGUIUtility.TrTextContent("Prebake Collision Meshes*", "Bake collision data into the meshes on build time");
97+
public static readonly GUIContent dedicatedServerOptimizations = EditorGUIUtility.TrTextContent("Enable Dedicated Server optimizations", "Performs additional optimizations on Dedicated Server builds.");
9798
public static readonly GUIContent keepLoadedShadersAlive = EditorGUIUtility.TrTextContent("Keep Loaded Shaders Alive*", "Prevents shaders from being unloaded");
9899
public static readonly GUIContent preloadedAssets = EditorGUIUtility.TrTextContent("Preloaded Assets*", "Assets to load at start up in the player and kept alive until the player terminates");
99100
public static readonly GUIContent stripEngineCode = EditorGUIUtility.TrTextContent("Strip Engine Code*", "Strip Unused Engine Code - Note that byte code stripping of managed assemblies is always enabled for the IL2CPP scripting backend.");
@@ -416,6 +417,7 @@ PlayerSettingsIconsEditor iconsEditor
416417
SerializedProperty m_KeepLoadedShadersAlive;
417418
SerializedProperty m_PreloadedAssets;
418419
SerializedProperty m_BakeCollisionMeshes;
420+
SerializedProperty m_DedicatedServerOptimizations;
419421
SerializedProperty m_ResizableWindow;
420422
SerializedProperty m_FullscreenMode;
421423
SerializedProperty m_VisibleInBackground;
@@ -638,6 +640,7 @@ void OnEnable()
638640
m_KeepLoadedShadersAlive = FindPropertyAssert("keepLoadedShadersAlive");
639641
m_PreloadedAssets = FindPropertyAssert("preloadedAssets");
640642
m_BakeCollisionMeshes = FindPropertyAssert("bakeCollisionMeshes");
643+
m_DedicatedServerOptimizations = FindPropertyAssert("dedicatedServerOptimizations");
641644
m_ResizableWindow = FindPropertyAssert("resizableWindow");
642645
m_UseMacAppStoreValidation = FindPropertyAssert("useMacAppStoreValidation");
643646
m_MacAppStoreCategory = FindPropertyAssert("macAppStoreCategory");
@@ -3192,6 +3195,9 @@ private void OtherSectionOptimizationGUI(BuildPlatform platform)
31923195
// Optimization
31933196
GUILayout.Label(SettingsContent.optimizationTitle, EditorStyles.boldLabel);
31943197

3198+
if (platform.namedBuildTarget == NamedBuildTarget.Server)
3199+
EditorGUILayout.PropertyField(m_DedicatedServerOptimizations, SettingsContent.dedicatedServerOptimizations);
3200+
31953201
EditorGUILayout.PropertyField(m_BakeCollisionMeshes, SettingsContent.bakeCollisionMeshes);
31963202

31973203
if (isPreset)

0 commit comments

Comments
 (0)