Skip to content

Commit b1cf2a8

Browse files
author
Unity Technologies
committed
Unity 6000.2.0a6 C# reference source code
1 parent b42ec00 commit b1cf2a8

File tree

121 files changed

+2911
-989
lines changed

Some content is hidden

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

121 files changed

+2911
-989
lines changed

Editor/Mono/AssemblyInfo/AssemblyInfo.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
[assembly: InternalsVisibleTo("Unity.IntegrationTests.Misc")]
5151
[assembly: InternalsVisibleTo("Unity.IntegrationTests.PackageManager")]
5252
[assembly: InternalsVisibleTo("Unity.IntegrationTests.Profiler")]
53+
[assembly: InternalsVisibleTo("Unity.IntegrationTests.PS4")]
54+
[assembly: InternalsVisibleTo("Unity.IntegrationTests.PS5")]
5355
[assembly: InternalsVisibleTo("Unity.IntegrationTests.Rendering")]
5456
[assembly: InternalsVisibleTo("Unity.IntegrationTests.SceneVisibility")]
5557
[assembly: InternalsVisibleTo("Unity.IntegrationTests.ScriptCompilation")]

Editor/Mono/BuildPlayerWindow.cs

Lines changed: 3 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -491,52 +491,9 @@ void OnGUI()
491491
{
492492
styles = new Styles();
493493
}
494-
495-
if (!UnityConnect.instance.canBuildWithUPID)
496-
{
497-
ShowAlert();
498-
}
499-
GUILayout.Space(5);
500-
GUILayout.BeginHorizontal();
501-
GUILayout.Space(10);
502-
GUILayout.BeginVertical();
503-
504-
string message = "";
505-
var buildSettingsLocked = !AssetDatabase.IsOpenForEdit(kEditorBuildSettingsPath, out message, StatusQueryOptions.UseCachedIfPossible);
506-
507-
using (new EditorGUI.DisabledScope(buildSettingsLocked))
508-
{
509-
ActiveScenesGUI();
510-
// Clear all and Add Current Scene
511-
GUILayout.BeginHorizontal();
512-
if (buildSettingsLocked)
513-
{
514-
GUI.enabled = true;
515-
if (GUILayout.Button(styles.checkOut))
516-
AssetDatabase.MakeEditable(kEditorBuildSettingsPath);
517-
GUILayout.Label(message);
518-
GUI.enabled = false;
519-
}
520-
GUILayout.FlexibleSpace();
521-
if (GUILayout.Button(styles.addOpenSource))
522-
AddOpenScenes();
523-
GUILayout.EndHorizontal();
524-
}
525-
526-
GUILayout.Space(10);
527-
528-
GUILayout.BeginHorizontal(GUILayout.Height(400));
529-
ActiveBuildTargetsGUI();
530-
GUILayout.Space(10);
531-
GUILayout.BeginVertical();
532-
ShowBuildTargetSettings();
533-
GUILayout.EndVertical();
534-
GUILayout.EndHorizontal();
535-
536-
GUILayout.Space(10);
537-
GUILayout.EndVertical();
538-
GUILayout.Space(10);
539-
GUILayout.EndHorizontal();
494+
// Override the 'old' build settings window in favor of the new build profile window.
495+
BuildPipeline.ShowBuildProfileWindow();
496+
Close();
540497
}
541498

542499
static bool IsAnyStandaloneModuleLoaded()

Editor/Mono/BuildProfile/BuildProfileAPI.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,41 @@ public static void SetActiveBuildProfile(BuildProfile buildProfile)
3333

3434
BuildProfileModuleUtil.SwitchLegacyActiveFromBuildProfile(buildProfile);
3535
}
36+
37+
/// <summary>
38+
/// Gets a component of type T associated with the build profile, its global fallback,
39+
/// or null if the component is not available.
40+
/// </summary>
41+
public T GetComponent<T>() where T : class
42+
{
43+
if (typeof(T) == typeof(PlayerSettings))
44+
{
45+
if (m_PlayerSettings != null)
46+
return m_PlayerSettings as T;
47+
return s_GlobalPlayerSettings as T;
48+
}
49+
50+
return null;
51+
}
52+
53+
/// <summary>
54+
/// Gets a component of type T associated with the currently active build profile,
55+
/// its global fallback, or null if the component is not available.
56+
/// </summary>
57+
public static T GetActiveComponent<T>() where T : class
58+
{
59+
var buildProfile = GetActiveBuildProfile();
60+
if (buildProfile == null)
61+
{
62+
if (typeof(T) == typeof(PlayerSettings))
63+
return s_GlobalPlayerSettings as T;
64+
}
65+
else
66+
{
67+
return buildProfile.GetComponent<T>();
68+
}
69+
70+
return null;
71+
}
3672
}
3773
}

Editor/Mono/BuildProfile/BuildProfileContext.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,5 +842,21 @@ static void Save() => InternalEditorUtility.SaveToSerializedFileAndForget(new[]
842842

843843
[VisibleToOtherModules]
844844
internal static bool IsSharedProfile(GUID platformGuid) => platformGuid.Empty();
845+
846+
internal static void UpdateScriptingDefineSymbolsInActivePlayerSettingsOverride(NamedBuildTarget buildTarget, string defines)
847+
{
848+
var profile = activeProfile;
849+
850+
if (profile == null)
851+
return;
852+
853+
if (profile.playerSettings == null)
854+
return;
855+
856+
PlayerSettings.SetScriptingDefineSymbols_Internal(profile.playerSettings, buildTarget.TargetName, defines);
857+
profile.SerializePlayerSettings();
858+
EditorUtility.SetDirty(profile);
859+
AssetDatabase.SaveAssetIfDirty(profile);
860+
}
845861
}
846862
}

Editor/Mono/BuildProfile/BuildProfileCreate.cs

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

55
using System;
6+
using System.IO;
67
using JetBrains.Annotations;
78
using UnityEditor.Modules;
89
using UnityEngine;
@@ -67,6 +68,7 @@ internal static void CreateInstance(GUID platformId, string assetPath)
6768
[VisibleToOtherModules("UnityEditor.BuildProfileModule")]
6869
internal static void CreateInstance(GUID platformId, string assetPath, int preconfiguredSettingsVariant, string[] packagesToAdd)
6970
{
71+
ValidateFileNameLength(assetPath);
7072
ValidatePlatform(platformId);
7173

7274
var (buildTarget, subtarget) = BuildProfileModuleUtil.GetBuildTargetAndSubtarget(platformId);
@@ -99,6 +101,18 @@ static void ValidatePlatform(GUID platformGuid)
99101
throw new ArgumentException("A build profile must be created for a valid platform.");
100102
}
101103

104+
/// <summary>
105+
/// Validates if the provided path name length is supported by the Asset database.
106+
/// Throws an ArgumentException if the platform is not valid.
107+
/// </summary>
108+
/// <param name="assetPath">The path to the build profile to be created.</param>
109+
static void ValidateFileNameLength(string assetPath)
110+
{
111+
// File name length is limited by the asset database
112+
if (Path.GetFileName(assetPath).Length > BuildProfileModuleUtil.k_MaxAssetFileNameLength)
113+
throw new ArgumentException($"Build profile name is too long ({Path.GetFileName(assetPath).Length}) - max supported is {BuildProfileModuleUtil.k_MaxAssetFileNameLength}");
114+
}
115+
102116
internal void NotifyBuildProfileExtensionOfCreation(int preconfiguredSettingsVariant)
103117
{
104118
var buildProfileExtension = BuildProfileModuleUtil.GetBuildProfileExtension(platformGuid);

Editor/Mono/BuildProfile/BuildProfileModuleUtil.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ internal class BuildProfileModuleUtil
2525
const string k_BuyProUrl = "https://store.unity.com/products/unity-pro";
2626
const string k_ConsoleModuleUrl = "https://unity3d.com/platform-installation";
2727
const string k_LastRunnableBuildPathSeparator = "_";
28+
// The asset database supports file name length to max. 250 symbols
29+
// Leave 3 symbols for the GenerateUniqueAssetPath() that adds " 1"(2,3...) in case
30+
// an asset with such name already exists.
31+
public const int k_MaxAssetFileNameLength = 247;
32+
// For UI cases where the extension `.asset` is not taken into consideration
33+
public const int k_MaxAssetFileNameLengthWithoutExtension = k_MaxAssetFileNameLength - 6;
2834
static readonly string k_NoModuleLoaded = L10n.Tr("No {0} module loaded.");
2935
static readonly string k_DerivedPlatformInactive = L10n.Tr("{0} is currently disabled.");
3036
static readonly string k_EditorWillNeedToBeReloaded = L10n.Tr("Note: Editor will need to be restarted to load any newly installed modules");

Editor/Mono/BuildProfile/BuildProfileRenameOverlay.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ internal class BuildProfileRenameOverlay
1818
{
1919
static readonly string k_InvalidChars = BuildProfileModuleUtil.GetFilenameInvalidCharactersStr();
2020
static readonly string k_ErrorMessage = string.Format(L10n.Tr("A file name can't contain any of the following characters:\t{0}"), k_InvalidChars);
21+
static readonly string k_ErrorMessageLength = string.Format(L10n.Tr("Build profile name can't be longer than {0} symbols"), BuildProfileModuleUtil.k_MaxAssetFileNameLengthWithoutExtension);
2122

2223
TextField m_TextField;
2324
Rect? m_ErrorRect = null;
@@ -56,6 +57,16 @@ public void OnNameChanged(string previousValue, string newValue)
5657
m_TextField.cursorIndex = targetIndex;
5758
m_TextField.selectIndex = targetIndex;
5859
}
60+
else if (newValue.Length > BuildProfileModuleUtil.k_MaxAssetFileNameLengthWithoutExtension)
61+
{
62+
TooltipView.Show(k_ErrorMessageLength, errorRect);
63+
m_TextField.SetValueWithoutNotify(previousValue);
64+
65+
// The cursor should be kept in place when adding too much
66+
var targetIndex = Mathf.Max(m_TextField.cursorIndex - 1, 0);
67+
m_TextField.cursorIndex = targetIndex;
68+
m_TextField.selectIndex = targetIndex;
69+
}
5970
else
6071
{
6172
TooltipView.ForceClose();

Editor/Mono/ContextMenuUtility.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,16 @@ public static void AddGameObjectEntriesTo(DropdownMenu menu)
169169
internal static DropdownMenu CreateActionMenu()
170170
{
171171
var contextMenu = new DropdownMenu();
172+
173+
Menu.CreateActionMenuBegin();
174+
172175
EditorToolManager.activeToolContext.PopulateMenu(contextMenu);
173176
AddMenuItemsForType(contextMenu, ToolManager.activeContextType, EditorToolManager.activeToolContext.targets);
174177
EditorToolManager.activeTool.PopulateMenu(contextMenu);
175178
AddMenuItemsForType(contextMenu, ToolManager.activeToolType, EditorToolManager.activeTool.targets);
176179

180+
Menu.CreateActionMenuEnd();
181+
177182
return contextMenu;
178183
}
179184

Editor/Mono/EditorGUI.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,7 @@ public virtual void EndEditing()
581581
{
582582
if (activeEditor == this)
583583
{
584+
activeEditor.m_HasFocus = false;
584585
activeEditor = null;
585586
}
586587

@@ -7683,7 +7684,7 @@ internal static bool DefaultPropertyField(Rect position, SerializedProperty prop
76837684
bool toggled = DropdownButton(position, toggleLabelContent, FocusType.Keyboard, EditorStyles.layerMaskField);
76847685
if (toggled)
76857686
{
7686-
PopupWindowWithoutFocus.Show(position, new MaskFieldDropDown(property));
7687+
PopupWindow.Show(position, new MaskFieldDropDown(property));
76877688
GUIUtility.ExitGUI();
76887689
}
76897690
break;

Editor/Mono/EditorSettings.bindings.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,9 @@ internal static extern string Internal_ProjectGenerationUserExtensions
242242
[StaticAccessor("GetEditorSettings()", StaticAccessorType.Dot)]
243243
public static extern bool useLegacyProbeSampleCount { get; set; }
244244

245+
[StaticAccessor("GetEditorSettings()", StaticAccessorType.Dot)]
246+
public static extern bool shadowmaskStitching { get; set; }
247+
245248
[Obsolete("The disableCookiesInLightmapper setting is no longer supported. Cookies are always enabled in the Progressive Lightmapper.", true)]
246249
public static bool disableCookiesInLightmapper
247250
{

0 commit comments

Comments
 (0)