Skip to content

Commit 940952f

Browse files
author
Unity Technologies
committed
Unity 6000.2.0a9 C# reference source code
1 parent c4aff6a commit 940952f

File tree

207 files changed

+2805
-931
lines changed

Some content is hidden

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

207 files changed

+2805
-931
lines changed

Editor/Mono/Animation/AnimationWindow/AnimationWindowHierarchy.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ internal class AnimationWindowHierarchy
4444
// Animation window shared state
4545
private AnimationWindowState m_State;
4646
private TreeViewController m_TreeView;
47+
private AnimationWindowHierarchyGUI m_HierarchyGUI;
4748

4849
public Vector2 GetContentSize()
4950
{
@@ -65,6 +66,7 @@ public void OnGUI(Rect position)
6566
{
6667
m_TreeView.OnEvent();
6768
m_TreeView.OnGUI(position, GUIUtility.GetControlID(FocusType.Keyboard));
69+
m_HierarchyGUI.ReclaimPendingFieldFocus();
6870
}
6971

7072
public void Init(EditorWindow owner, Rect rect)
@@ -74,9 +76,10 @@ public void Init(EditorWindow owner, Rect rect)
7476

7577
m_TreeView = new TreeViewController(owner, m_State.hierarchyState);
7678
m_State.hierarchyData = new AnimationWindowHierarchyDataSource(m_TreeView, m_State);
79+
m_HierarchyGUI = new AnimationWindowHierarchyGUI(m_TreeView, m_State);
7780
m_TreeView.Init(rect,
7881
m_State.hierarchyData,
79-
new AnimationWindowHierarchyGUI(m_TreeView, m_State),
82+
m_HierarchyGUI,
8083
null
8184
);
8285

Editor/Mono/Animation/AnimationWindow/AnimationWindowHierarchyGUI.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ internal class AnimationWindowHierarchyGUI : TreeViewGUI
3030
private int[] m_HierarchyItemValueControlIDs;
3131
private int[] m_HierarchyItemButtonControlIDs;
3232

33+
private bool m_NeedsToReclaimFieldFocus;
34+
private int m_FieldToReclaimFocus;
35+
3336
private const float k_RowRightOffset = 10;
3437
private const float k_ValueFieldDragWidth = 15;
3538
private const float k_ValueFieldWidth = 80;
@@ -352,11 +355,12 @@ private void DoValueField(Rect rect, AnimationWindowHierarchyNode node, int row)
352355
&& Event.current.type == EventType.KeyDown
353356
&& (Event.current.character == '\n' || (int)Event.current.character == 3));
354357

355-
// Force back keyboard focus to float field editor when editing it.
356-
// TreeView forces keyboard focus on itself at mouse down and we lose focus here.
358+
// Force back keyboard focus to float field editor when editing it since the TreeView forces keyboard focus on itself at mouse down.
359+
// The focus will be reclaimed after the TreeViewController.OnGUI call.
357360
if (EditorGUI.s_RecycledEditor.controlID == id && Event.current.type == EventType.MouseDown && valueFieldRect.Contains(Event.current.mousePosition))
358361
{
359-
GUIUtility.keyboardControl = id;
362+
m_NeedsToReclaimFieldFocus = true;
363+
m_FieldToReclaimFocus = id;
360364
}
361365

362366
if (curve.isDiscreteCurve)
@@ -421,6 +425,15 @@ private void DoValueField(Rect rect, AnimationWindowHierarchyNode node, int row)
421425
}
422426
}
423427

428+
internal void ReclaimPendingFieldFocus()
429+
{
430+
if (m_NeedsToReclaimFieldFocus)
431+
{
432+
GUIUtility.keyboardControl = m_FieldToReclaimFocus;
433+
m_NeedsToReclaimFieldFocus = false;
434+
}
435+
}
436+
424437
private bool DoTreeViewButton(int id, Rect position, GUIContent content, GUIStyle style)
425438
{
426439
Event evt = Event.current;

Editor/Mono/AssemblyInfo/AssemblyInfo.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
[assembly: InternalsVisibleTo("Unity.IntegrationTests.Profiler")]
5353
[assembly: InternalsVisibleTo("Unity.IntegrationTests.PS4")]
5454
[assembly: InternalsVisibleTo("Unity.IntegrationTests.PS5")]
55+
[assembly: InternalsVisibleTo("Unity.IntegrationTests.Switch")]
5556
[assembly: InternalsVisibleTo("Unity.IntegrationTests.Rendering")]
5657
[assembly: InternalsVisibleTo("Unity.IntegrationTests.SceneVisibility")]
5758
[assembly: InternalsVisibleTo("Unity.IntegrationTests.ScriptCompilation")]
@@ -147,7 +148,7 @@
147148
[assembly: InternalsVisibleTo("Unity.XR.Remoting.Editor")]
148149
[assembly: InternalsVisibleTo("UnityEngine.Common")]
149150
[assembly: InternalsVisibleTo("Unity.UI.Builder.Editor")]
150-
[assembly: InternalsVisibleTo("UnityEditor.UIElements.Tests.Tests")] // for UI Test Framework
151+
[assembly: InternalsVisibleTo("Unity.UI.TestFramework.Editor.Tests")] // for UI Test Framework
151152
[assembly: InternalsVisibleTo("UnityEditor.UIBuilderModule")]
152153
[assembly: InternalsVisibleTo("Unity.UI.Builder.EditorTests")]
153154
[assembly: InternalsVisibleTo("Unity.GraphViewTestUtilities.Editor")]
@@ -175,8 +176,8 @@
175176

176177
[assembly: InternalsVisibleTo("Unity.Entities.Build")]
177178

178-
[assembly: InternalsVisibleTo("Unity.Muse.Common.Bridge")]
179179
[assembly: InternalsVisibleTo("Unity.Muse.Chat.Bridge")]
180+
[assembly: InternalsVisibleTo("Unity.AI.Assistant.Bridge.Editor")]
180181

181182
[assembly: InternalsVisibleTo("Unity.Multiplayer.Playmode.Editor.Bridge")]
182183
[assembly: InternalsVisibleTo("Unity.DedicatedServer.Editor.Bridge")]

Editor/Mono/AssetDatabase/AssetPreview.bindings.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ public static Texture2D GetAssetPreview(Object asset)
2222
return null;
2323
}
2424

25-
internal static Texture2D GetAssetPreview(int instanceID)
25+
internal static Texture2D GetAssetPreview(EntityId entityId)
2626
{
27-
return GetAssetPreview(instanceID, kSharedClientID);
27+
return GetAssetPreview(entityId, kSharedClientID);
2828
}
2929

3030
[FreeFunction("AssetPreviewBindings::GetAssetPreview")]
31-
internal static extern Texture2D GetAssetPreview(int instanceID, int clientID);
31+
internal static extern Texture2D GetAssetPreview(EntityId entityId, int clientID);
3232

3333
[FreeFunction("AssetPreviewBindings::HasAssetPreview")]
34-
internal static extern bool HasAssetPreview(int instanceID, int clientID);
34+
internal static extern bool HasAssetPreview(EntityId entityId, int clientID);
3535

3636
internal static Texture2D GetAssetPreviewFromGUID(string guid)
3737
{
@@ -46,8 +46,13 @@ public static bool IsLoadingAssetPreview(int instanceID)
4646
return IsLoadingAssetPreview(instanceID, kSharedClientID);
4747
}
4848

49+
public static bool IsLoadingAssetPreview(EntityId entityId)
50+
{
51+
return IsLoadingAssetPreview(entityId, kSharedClientID);
52+
}
53+
4954
[FreeFunction("AssetPreviewBindings::IsLoadingAssetPreview")]
50-
internal static extern bool IsLoadingAssetPreview(int instanceID, int clientID);
55+
internal static extern bool IsLoadingAssetPreview(EntityId entityId, int clientID);
5156

5257
public static bool IsLoadingAssetPreviews()
5358
{

Editor/Mono/AssetPipeline/SpeedTree/SpeedTree9ImporterModelEditor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ internal bool DoMaterialsHaveDifferentShader()
273273
{
274274
prefabs[i] = assetTargets[i] as GameObject;
275275
}
276-
276+
277277
List<SpeedTree9Importer> importerArray = new List<SpeedTree9Importer>();
278278
foreach (SpeedTree9Importer importer in importers)
279279
{
@@ -345,7 +345,7 @@ private void ShowLODGUI()
345345
string[] heightsFormated = new string[heights.Length];
346346
for (int i = 0; i < heights.Length; ++i)
347347
{
348-
heightsFormated[i] = UnityString.Format("{0:0}%", heights[i] * 100);
348+
heightsFormated[i] = string.Format("{0:0}%", heights[i] * 100);
349349
}
350350

351351
var menuText = String.Format("{0}: {1}",
@@ -640,7 +640,7 @@ private void DrawLODSettingCustomizationGUI(List<LODGroupGUI.LODInfo> lods, int
640640
}
641641
else
642642
{
643-
// Toggle
643+
// Toggle
644644
GUIContent customizationLabel = EditorGUIUtility.TrTextContent(String.Format("Customize {0} options", lods[lodIndex].LODName), "To override options for a certain LOD, check this box and select the LOD from the LOD slider above");
645645
EditorGUILayout.PropertyField(lodSettingOverride, customizationLabel);
646646

Editor/Mono/AssetStore/AssetStoreAsset.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ private static string intToSizeString(int inValue)
681681
if (idx < 0)
682682
return "<error>";
683683

684-
return UnityString.Format("{0:#.##} {1}", val, scale[idx]);
684+
return string.Format("{0:#.##} {1}", val, scale[idx]);
685685
}
686686

687687
public override bool HasPreviewGUI()

Editor/Mono/Audio/Mixer/GUI/AudioMixerChannelStripView.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ string GetEffectSlotName(AudioMixerEffectController effect, bool showLevel, Audi
514514
{
515515
if (m_ChangingWetMixIndex == m_IndexCounter && showLevel)
516516
{
517-
return UnityString.Format("{0:F1} dB", effect.GetValueForMixLevel(m_Controller, snapshot));
517+
return string.Format("{0:F1} dB", effect.GetValueForMixLevel(m_Controller, snapshot));
518518
}
519519

520520
if (effect.IsSend() && effect.sendTarget != null)

Editor/Mono/BuildProfile/BuildProfileModuleUtil.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,15 @@ public static VisualElement CreateModuleNotInstalledElement(GUID platformId)
182182
return new IMGUIContainer(() =>
183183
{
184184
GUILayout.Label(EditorGUIUtility.TextContent(text), EditorStyles.wordWrappedLabel);
185+
186+
EditorGUILayout.BeginHorizontal();
187+
// Add the space to align the button with text
188+
GUILayout.Space(6);
185189
if (GUILayout.Button("Contact Sales", EditorStyles.miniButton, GUILayout.ExpandWidth(false)))
186190
{
187191
Help.BrowseURL(url);
188192
}
193+
EditorGUILayout.EndHorizontal();
189194
});
190195
}
191196

Editor/Mono/BuildTargetDiscovery.bindings.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ public PlatformInfo() {}
360360
buildTarget = BuildTarget.Android,
361361
nameAndLinkToShowUnderTitle = new List<NameAndLink>
362362
{
363-
new NameAndLink{name = L10n.Tr("Unity Android Manual"), linkUrl = "https://docs.unity3d.com/Manual/android.html"},
363+
new NameAndLink{name = L10n.Tr("Unity Android Manual"), linkUrl = $"https://docs.unity3d.com/{Help.GetShortReleaseVersion()}/Documentation/Manual/android.html"},
364364
},
365365
iconName = "BuildSettings.Android",
366366
flags = PlatformAttributes.IsWindowsBuildTarget | PlatformAttributes.IsWindowsArm64BuildTarget | PlatformAttributes.IsLinuxBuildTarget | PlatformAttributes.IsMacBuildTarget
@@ -512,9 +512,13 @@ public PlatformInfo() {}
512512
{
513513
displayName = "Meta Quest",
514514
downloadLinkName = "Android",
515+
description = L10n.Tr(
516+
"Take advantage of Unity's support for Meta Quest platforms and leverage Unity's extensive XR tools and frameworks. " +
517+
"This platform offers default project settings and configurations for a streamlined publishing process."
518+
),
515519
buildTarget = BuildTarget.Android,
516520
iconName = "BuildSettings.Meta",
517-
requiredPackage = new string[]{L10n.Tr("com.unity.xr.meta-openxr") },
521+
requiredPackage = new string[]{L10n.Tr("com.unity.xr.openxr") },
518522
flags = PlatformAttributes.IsWindowsBuildTarget | PlatformAttributes.IsWindowsArm64BuildTarget | PlatformAttributes.IsLinuxBuildTarget | PlatformAttributes.IsMacBuildTarget | PlatformAttributes.IsDerivedBuildTarget
519523
}
520524
},
@@ -523,6 +527,8 @@ public PlatformInfo() {}
523527
new PlatformInfo
524528
{
525529
displayName = "Android XR",
530+
downloadLinkName = "Android",
531+
description = L10n.Tr("Android XR provides a strong foundation for high-performance, immersive experiences. OpenXR conformance ensures support for widely used XR extensions, while cross-platform tools provide a familiar development experience. The Android XR build profile offers pre-configured settings tailored for Android XR development, making getting started fast and easy."),
526532
buildTarget = BuildTarget.Android,
527533
iconName = "BuildSettings.Android",
528534
requiredPackage = new string[]{L10n.Tr("com.unity.xr.androidxr-openxr") },

Editor/Mono/CodeEditor/DefaultExternalCodeEditor.cs

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@
88
using Unity.CodeEditor;
99
using UnityEditorInternal;
1010
using UnityEngine;
11+
using UnityEngine.Assertions;
12+
using NiceIO;
1113

1214
namespace UnityEditor
1315
{
1416
internal class DefaultExternalCodeEditor : IExternalCodeEditor
1517
{
1618
static readonly GUIContent k_ResetArguments = EditorGUIUtility.TrTextContent("Reset argument");
17-
static readonly string[] supportedExtensions = {"json", "asmdef", "log", "cs", "uxml", "uss", "shader", "compute", "cginc", "hlsl", "glslinc", "template", "raytrace" };
19+
static readonly string[] supportedExtensions = { "json", "asmdef", "log", "cs", "uxml", "uss", "shader", "compute", "cginc", "hlsl", "glslinc", "template", "raytrace" };
1820
static bool IsOSX => Application.platform == RuntimePlatform.OSXEditor;
1921
static bool IsWindows => Application.platform == RuntimePlatform.WindowsEditor;
2022
static bool IsLinux => Application.platform == RuntimePlatform.LinuxEditor;
@@ -37,7 +39,7 @@ string Arguments
3739
// So on OSX we change the key for per application for script editor args,
3840
// to avoid reading the one from previous versions.
3941
// The year 2021: Delete mac hack.
40-
if (Application.platform == RuntimePlatform.OSXEditor)
42+
if (IsOSX)
4143
{
4244
var oldMac = EditorPrefs.GetString("kScriptEditorArgs_" + Installation);
4345
if (!string.IsNullOrEmpty(oldMac))
@@ -50,7 +52,7 @@ string Arguments
5052
}
5153
set
5254
{
53-
if (Application.platform == RuntimePlatform.OSXEditor)
55+
if (IsOSX)
5456
{
5557
EditorPrefs.SetString("kScriptEditorArgs_" + Installation, value);
5658
}
@@ -134,37 +136,37 @@ public bool OpenProject(string path, int line, int column)
134136
return false;
135137
}
136138

137-
string applicationPath = CodeEditor.CurrentEditorPath.Trim();
139+
var applicationPath = CodeEditor.CurrentEditorPath.Trim();
140+
var doesNotExistWarning =
141+
$"External Code Editor application path does not exist ({applicationPath})! Please select a different application.";
138142

139-
if (!string.IsNullOrEmpty(applicationPath) && !File.Exists(applicationPath))
143+
var npath = new NPath(applicationPath);
144+
if (applicationPath == null || !npath.Exists())
140145
{
141-
UnityEngine.Debug.LogWarning($"External Code Editor application path does not exist ({applicationPath})! Please select a different application");
146+
UnityEngine.Debug.LogWarning(doesNotExistWarning);
147+
return false;
142148
}
143149

144150
if (applicationPath == CodeEditor.SystemDefaultPath)
145151
{
146152
return InternalEditorUtility.OpenFileAtLineExternal(path, -1, -1);
147153
}
148154

149-
if (IsOSX)
150-
{
151-
return CodeEditor.OSOpenFile(applicationPath, CodeEditor.ParseArgument(Arguments, path, line, column));
152-
}
153-
154155
string fileName = "";
155156
string arguments = "";
156-
157-
if (IsLinux)
158-
{
159-
fileName = applicationPath;
160-
arguments = CodeEditor.ParseArgument(Arguments, path, line, column);
161-
}
162-
163-
if (IsWindows)
157+
switch (Application.platform)
164158
{
165-
fileName = "cmd.exe";
166-
arguments = "/C \"" + CodeEditor.QuoteForProcessStart(applicationPath) +
167-
" " + CodeEditor.ParseArgument(Arguments, path, line, column) + "\"";
159+
case RuntimePlatform.OSXEditor:
160+
return CodeEditor.OSOpenFile(applicationPath, CodeEditor.ParseArgument(Arguments, path, line, column));
161+
case RuntimePlatform.LinuxEditor:
162+
fileName = applicationPath;
163+
arguments = CodeEditor.ParseArgument(Arguments, path, line, column);
164+
break;
165+
case RuntimePlatform.WindowsEditor:
166+
fileName = "cmd.exe";
167+
arguments = "/C \"" + CodeEditor.QuoteForProcessStart(applicationPath) +
168+
" " + CodeEditor.ParseArgument(Arguments, path, line, column) + "\"";
169+
break;
168170
}
169171

170172
var process = new Process

Editor/Mono/DefaultAsset.bindings.cs

Lines changed: 26 additions & 0 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 System.IO;
57
using UnityEngine.Bindings;
68
using UnityEngine.UIElements;
79

@@ -11,8 +13,21 @@ namespace UnityEditor
1113
// This class is public for users to be able to make custom editors for this type (see case 656580)
1214
public class DefaultAsset : UnityEngine.Object
1315
{
16+
internal enum ErrorCodes
17+
{
18+
NoError,
19+
PrefabCorruptedFileIds,
20+
ImportFail_TooMuch_Data,
21+
ImportFail_MetaFile_GUID_Mismatch,
22+
ImportFail_ImporterCrashed,
23+
ErrorCodeCount
24+
};
25+
1426
private protected DefaultAsset() {}
1527
internal extern string message { get; }
28+
29+
internal extern int errorCode { get; }
30+
1631
internal extern bool isWarning {[NativeName("IsWarning")] get; }
1732
}
1833

@@ -31,6 +46,17 @@ public override VisualElement CreateInspectorGUI()
3146
defaultAsset.isWarning ? HelpBoxMessageType.Warning : HelpBoxMessageType.Info);
3247
container.Add(helpBox);
3348
}
49+
if (defaultAsset.errorCode == (int)DefaultAsset.ErrorCodes.ImportFail_MetaFile_GUID_Mismatch)
50+
{
51+
var button = new Button(() =>
52+
{
53+
var metaPath = AssetDatabase.GetAssetPath(target).Trim('/') + ".meta";
54+
File.SetLastWriteTimeUtc(metaPath,DateTime.UtcNow);
55+
AssetDatabase.Refresh();
56+
});
57+
button.text = "Fix Now";
58+
container.Add(button);
59+
}
3460

3561
return container;
3662
}

Editor/Mono/EditorGraphicsSettings.bindings.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ public static void SetRenderPipelineGlobalSettingsAsset(Type renderPipelineType,
8484
RenderPipelineManager.RecreateCurrentPipeline(rpAsset);
8585
}
8686

87+
//Removing a globalSeetings and adding back another one from the same type will cause issue in the Notifier persistency cache
88+
Notifier.RecomputeDictionary();
89+
8790
GraphicsSettingsInspectorUtility.ReloadGraphicsSettingsEditorIfNeeded();
8891
}
8992

0 commit comments

Comments
 (0)