Skip to content

Commit c68d1e1

Browse files
author
Unity Technologies
committed
Unity 6000.0.50f1 C# reference source code
1 parent 96a26ec commit c68d1e1

File tree

115 files changed

+1864
-743
lines changed

Some content is hidden

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

115 files changed

+1864
-743
lines changed

Editor/Mono/AttributeHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ static MonoGizmoMethod[] ExtractGizmos(Assembly assembly)
112112
}
113113

114114
[RequiredByNativeCode]
115-
static string GetComponentMenuName(Type type)
115+
static object GetComponentMenuName(Type type)
116116
{
117117
var attrs = type.GetCustomAttributes(typeof(AddComponentMenu), false);
118118
if (attrs.Length > 0)

Editor/Mono/EditorApplication.bindings.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ namespace UnityEditor
2121
[NativeHeader("Runtime/Input/TimeManager.h")]
2222
[NativeHeader("Editor/Src/ProjectVersion.h")]
2323
[NativeHeader("Runtime/Misc/BuildSettings.h")]
24+
[NativeHeader("Runtime/Interfaces/ILicensing.h")]
2425
[StaticAccessor("EditorApplicationBindings", StaticAccessorType.DoubleColon)]
2526
public sealed partial class EditorApplication
2627
{
@@ -139,7 +140,7 @@ public static ScriptingRuntimeVersion scriptingRuntimeVersion
139140
get { return ScriptingRuntimeVersion.Latest; }
140141
}
141142

142-
[StaticAccessor("GetApplication()", StaticAccessorType.Dot)]
143+
[StaticAccessor("GetILicensing()", StaticAccessorType.Arrow)]
143144
internal static extern string GetLicenseType();
144145

145146
// Prevents loading of assemblies when it is inconvenient.

Editor/Mono/Inspector/PlayerSettingsEditor/PlayerSettingsEditor.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ class SettingsContent
210210
public static readonly GUIContent managedStrippingLevel = EditorGUIUtility.TrTextContent("Managed Stripping Level", "If scripting backend is IL2CPP, managed stripping can't be disabled.");
211211
public static readonly GUIContent il2cppCompilerConfiguration = EditorGUIUtility.TrTextContent("C++ Compiler Configuration");
212212
public static readonly GUIContent il2cppCodeGeneration = EditorGUIUtility.TrTextContent("IL2CPP Code Generation", "Determines whether IL2CPP should generate code optimized for runtime performance or build size/iteration.");
213-
public static readonly GUIContent[] il2cppCodeGenerationNames = new GUIContent[] { EditorGUIUtility.TrTextContent("Faster runtime"), EditorGUIUtility.TrTextContent("Faster (smaller) builds") };
213+
public static readonly GUIContent[] il2cppCodeGenerationNames = new GUIContent[] { EditorGUIUtility.TrTextContent("Optimize for runtime speed"), EditorGUIUtility.TrTextContent("Optimize for code size and build time") };
214214
public static readonly GUIContent il2cppStacktraceInformation = EditorGUIUtility.TrTextContent("IL2CPP Stacktrace Information", "Which information to include in stack traces. Including the file name and line number may increase build size.");
215215
public static readonly GUIContent scriptingMono2x = EditorGUIUtility.TrTextContent("Mono");
216216
public static readonly GUIContent scriptingIL2CPP = EditorGUIUtility.TrTextContent("IL2CPP");
@@ -1030,7 +1030,7 @@ private bool HasReasonToCompile()
10301030

10311031
private bool SupportsRunInBackground(NamedBuildTarget buildTarget)
10321032
{
1033-
return buildTarget == NamedBuildTarget.Standalone;
1033+
return buildTarget == NamedBuildTarget.Standalone || buildTarget == NamedBuildTarget.VisionOS;
10341034
}
10351035

10361036
private void OnPresetSelectorClosed()
@@ -2095,10 +2095,12 @@ private void OtherSectionShaderSettingsGUI(BuildPlatform platform)
20952095
SettingsContent.shaderPrecisionModelOptions);
20962096
if (EditorGUI.EndChangeCheck() && currShaderPrecisionModel != newShaderPrecisionModel)
20972097
{
2098-
m_ShaderPrecisionModel.intValue = (int) newShaderPrecisionModel;
2098+
m_ShaderPrecisionModel.intValue = (int)newShaderPrecisionModel;
20992099
serializedObject.ApplyModifiedProperties();
21002100
if (IsActivePlayerSettingsEditor())
2101-
PlayerSettings.SyncShaderPrecisionModel();
2101+
{
2102+
EditorApplication.delayCall += () => PlayerSettings.SyncShaderPrecisionModel();
2103+
}
21022104
}
21032105
}
21042106

Editor/Mono/Inspector/UnityEventDrawer.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,23 @@ static PersistentListenerMode GetMode(SerializedProperty mode)
369369
return (PersistentListenerMode)mode.enumValueIndex;
370370
}
371371

372+
internal static bool ShouldClearMethodAfterTargetChanged(SerializedProperty listener, Object newValue)
373+
{
374+
// If the type is the same we dont need to clear the method
375+
var typeProperty = listener.FindPropertyRelative(kInstanceTypePath);
376+
var typeString = typeProperty.stringValue;
377+
if (!string.IsNullOrEmpty(typeString))
378+
{
379+
var objType = Type.GetType(typeString, false);
380+
381+
if (objType == null || newValue == null || newValue.GetType() != objType)
382+
return true;
383+
}
384+
385+
// Clear if the value is null
386+
return newValue == null;
387+
}
388+
372389
protected virtual void DrawEvent(Rect rect, int index, bool isActive, bool isFocused)
373390
{
374391
var pListener = m_ListenersArray.GetArrayElementAtIndex(index);
@@ -396,8 +413,10 @@ protected virtual void DrawEvent(Rect rect, int index, bool isActive, bool isFoc
396413
{
397414
GUI.Box(goRect, GUIContent.none);
398415
EditorGUI.PropertyField(goRect, listenerTarget, GUIContent.none);
399-
if (EditorGUI.EndChangeCheck())
416+
if (EditorGUI.EndChangeCheck() && ShouldClearMethodAfterTargetChanged(pListener, listenerTarget.objectReferenceValue))
417+
{
400418
methodName.stringValue = null;
419+
}
401420
}
402421

403422
SerializedProperty argument = GetArgument(pListener);

Editor/Mono/UIElements/DefaultMainToolbar.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ static IEnumerable<string> leftToolbar
2020
yield return "Services/Version Control";
2121
//Modules/EditorToolbar/ToolbarElements/*.cs
2222
yield return "Editor Utility/Store";
23+
yield return "Package Management/Package Manager";
2324
//Editor/Mono/GUI/Toolbars/MainToolbarImguiContainer.cs
2425
yield return "Editor Utility/Imgui Subtoolbars";
2526
}
@@ -42,7 +43,6 @@ static IEnumerable<string> rightToolbar
4243
yield return "Editor Utility/Layout";
4344
yield return "Editor Utility/Search";
4445
yield return "Editor Utility/Modes";
45-
yield return "Package Manager/PreviewPackagesInUse";
4646
yield return "Editor Utility/Undo";
4747
// Modules/Multiplayer/MultiplayerRoleDropdown.cs
4848
yield return "Multiplayer/MultiplayerRole";

Editor/Mono/UIElements/Drawers/Internal/UnityEventItem.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,10 @@ public UnityEventItem()
113113
leftColumn.Add(listenerTarget);
114114
listenerTarget.RegisterCallback<ChangeEvent<UnityEngine.Object>>((e) =>
115115
{
116-
var isTargetValid = e.newValue != null;
117-
118-
if (!isTargetValid)
119-
{
116+
if (UnityEventDrawer.ShouldClearMethodAfterTargetChanged(m_PropertyData.listener, e.newValue))
120117
functionDropdown.value = null;
121-
}
122118

123-
functionDropdown.SetEnabled(isTargetValid);
119+
functionDropdown.SetEnabled(e.newValue != null);
124120

125121
UpdateParameterField();
126122
});

Modules/AssetPipelineEditor/ImportSettings/PluginImporterInspector.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@ internal enum Compatibility : int
9696

9797
private Compatibility m_Preload;
9898

99-
private readonly static BuildTarget[] m_StandaloneTargets = BuildTargetDiscovery.StandaloneBuildTargets;
100-
10199
internal class DefineConstraint
102100
{
103101
public string name;
@@ -174,15 +172,15 @@ private static int GetPlatformGroupArraySize()
174172

175173
private static bool IsStandaloneTarget(BuildTarget buildTarget)
176174
{
177-
return m_StandaloneTargets.Contains(buildTarget);
175+
return BuildTargetDiscovery.StandaloneBuildTargets.Contains(buildTarget);
178176
}
179177

180178
private Compatibility compatibleWithStandalone
181179
{
182180
get
183181
{
184182
bool compatible = false;
185-
foreach (var t in m_StandaloneTargets)
183+
foreach (var t in BuildTargetDiscovery.StandaloneBuildTargets)
186184
{
187185
// Return mixed value if one of the values is mixed
188186
if (m_CompatibleWithPlatform[(int)t] == Compatibility.Mixed)
@@ -196,7 +194,7 @@ private Compatibility compatibleWithStandalone
196194

197195
set
198196
{
199-
foreach (var t in m_StandaloneTargets)
197+
foreach (var t in BuildTargetDiscovery.StandaloneBuildTargets)
200198
m_CompatibleWithPlatform[(int)t] = value;
201199
}
202200
}

Modules/BuildProfileEditor/BuildProfileWindow.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,16 @@ internal void RepaintAndClearSelection()
317317
/// <see cref="m_BuildProfileContextMenu"/>.
318318
/// </summary>
319319
internal BuildProfileListEditableLabel CreateEditableLabelItem() => new BuildProfileListEditableLabel(
320-
m_BuildProfileContextMenu.UpdateBuildProfileLabelName,
320+
(object buildProfileObject, string buildProfileLabelName) =>
321+
{
322+
bool isUpdated = m_BuildProfileContextMenu.UpdateBuildProfileLabelName(buildProfileObject, buildProfileLabelName);
323+
if (isUpdated)
324+
{
325+
// The same path is used to force a repaint of the profile editor
326+
OnBuildProfileCreated(buildProfileObject as BuildProfile);
327+
}
328+
return isUpdated;
329+
},
321330
m_BuildProfileContextMenu.AddBuildProfileContextMenu());
322331

323332
/// <summary>

Modules/BuildProfileEditor/Handlers/BuildProfileWindowSelection.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ internal enum ListViewSelectionType
3030
readonly Label m_SelectedProfilePlatformLabel;
3131

3232
readonly List<BuildProfile> m_SelectedBuildProfiles;
33+
readonly Dictionary<GUID, int> m_MultiSelectLabelCountMap;
3334

3435
internal bool IsSingleSelection() => m_SelectedBuildProfiles.Count == 1;
3536
internal bool IsMultipleSelection() => m_SelectedBuildProfiles.Count > 1;
@@ -44,6 +45,7 @@ internal BuildProfileWindowSelection(VisualElement rootVisualElement, PlatformLi
4445
{
4546
m_PlatformListViews = platformListView;
4647
m_SelectedBuildProfiles = new List<BuildProfile>();
48+
m_MultiSelectLabelCountMap = new Dictionary<GUID, int>();
4749
m_SelectedProfileImage = rootVisualElement.Q<Image>("selected-profile-image");
4850
m_SelectedProfileNameLabel = rootVisualElement.Q<Label>("selected-profile-name");
4951
m_SelectedProfilePlatformLabel = rootVisualElement.Q<Label>("selected-profile-platform");
@@ -55,6 +57,7 @@ internal void UpdateSelectionGUI(BuildProfile profile)
5557
{
5658
m_SelectedProfileImage.image = BuildProfileModuleUtil.GetPlatformIcon(string.Empty);
5759
m_SelectedProfileNameLabel.text = $"{m_SelectedBuildProfiles.Count} Build Profiles";
60+
m_SelectedProfilePlatformLabel.text = GetMultiSelectLabelString();
5861
}
5962
else
6063
{
@@ -170,5 +173,34 @@ internal void ClearSelectedProfiles()
170173
{
171174
m_SelectedBuildProfiles.Clear();
172175
}
176+
177+
string GetMultiSelectLabelString()
178+
{
179+
string labelText = string.Empty;
180+
181+
foreach (var buildProfile in m_SelectedBuildProfiles)
182+
{
183+
if (!m_MultiSelectLabelCountMap.TryAdd(new GUID(buildProfile.platformId), 1))
184+
{
185+
m_MultiSelectLabelCountMap[new GUID(buildProfile.platformId)]++;
186+
}
187+
}
188+
189+
int index = 0;
190+
foreach (var platform in m_MultiSelectLabelCountMap)
191+
{
192+
var platformName = BuildProfileModuleUtil.GetClassicPlatformDisplayName(platform.Key.ToString());
193+
labelText += $"{platform.Value} {platformName}";
194+
195+
if (++index < m_MultiSelectLabelCountMap.Count)
196+
{
197+
labelText += ", ";
198+
}
199+
}
200+
201+
labelText += $" {TrText.buildProfilesName}";
202+
m_MultiSelectLabelCountMap.Clear();
203+
return labelText;
204+
}
173205
}
174206
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// Unity C# reference source
2+
// Copyright (c) Unity Technologies. For terms of use, see
3+
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
4+
5+
using System;
6+
using UnityEditor.PackageManager.UI;
7+
using UnityEditor.PackageManager.UI.Internal;
8+
using UnityEditor.UIElements;
9+
using UnityEngine.UIElements;
10+
11+
namespace UnityEditor.Toolbars
12+
{
13+
[EditorToolbarElement("Package Management/Package Manager", typeof(DefaultMainToolbar))]
14+
sealed class PackageManagerButton : ToolbarButton
15+
{
16+
private readonly IPackageDatabase m_PackageDatabase;
17+
private readonly VisualElement m_Icon;
18+
private Action m_ClickAction;
19+
20+
public PackageManagerButton()
21+
{
22+
m_PackageDatabase = ServicesContainer.instance.Resolve<IPackageDatabase>();
23+
RegisterCallback<AttachToPanelEvent>(OnAttachedToPanel);
24+
RegisterCallback<DetachFromPanelEvent>(OnDetachFromPanel);
25+
26+
name = "PackageManager";
27+
28+
m_Icon = new VisualElement { name = "image" };
29+
Add(m_Icon);
30+
AddToClassList("unity-toolbar-button-package-manager");
31+
32+
clicked += OnPackageManagerButtonClicked;
33+
34+
RefreshState();
35+
}
36+
37+
private void OnAttachedToPanel(AttachToPanelEvent _)
38+
{
39+
m_PackageDatabase.onPackagesChanged += OnPackagesChanged;
40+
}
41+
42+
private void OnPackagesChanged(PackagesChangeArgs _)
43+
{
44+
RefreshState();
45+
}
46+
47+
private void OnDetachFromPanel(DetachFromPanelEvent _)
48+
{
49+
m_PackageDatabase.onPackagesChanged -= OnPackagesChanged;
50+
}
51+
52+
private void RefreshState()
53+
{
54+
m_Icon.ClearClassList();
55+
56+
if (m_PackageDatabase.AnyNonCompliantPackagesInUse())
57+
{
58+
m_Icon.AddToClassList("error");
59+
tooltip = L10n.Tr("Restricted Packages In Use");
60+
m_ClickAction = () => PackageManagerWindow.OpenAndSelectPage(InProjectNonCompliancePage.k_Id);
61+
}
62+
else if (m_PackageDatabase.AnyExperimentalPackagesInUse())
63+
{
64+
m_Icon.AddToClassList("warning");
65+
tooltip = L10n.Tr("Experimental Packages In Use");
66+
m_ClickAction = () => PackageManagerWindow.OpenAndSelectPage(InProjectPage.k_Id, "experimental");
67+
}
68+
else
69+
{
70+
m_Icon.AddToClassList("default");
71+
tooltip = L10n.Tr("Package Manager");
72+
m_ClickAction = () => PackageManagerWindow.OpenAndSelectPackage(null);
73+
}
74+
}
75+
76+
private void OnPackageManagerButtonClicked()
77+
{
78+
m_ClickAction?.Invoke();
79+
}
80+
}
81+
}

0 commit comments

Comments
 (0)