Skip to content

Commit d6f29af

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

File tree

163 files changed

+2399
-1272
lines changed

Some content is hidden

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

163 files changed

+2399
-1272
lines changed

Editor/Mono/2D/SpriteAtlas/SpriteAtlasImporter.bindings.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
namespace UnityEditor.U2D
1616
{
1717
// SpriteAtlas Importer lets you modify [[SpriteAtlas]]
18-
[HelpURL("https://docs.unity3d.com/2023.2/Documentation/Manual/SpriteAtlasV2.html")]
18+
[HelpURL("https://docs.unity3d.com/6000.2/Documentation/Manual/sprite/atlas/v2/sprite-atlas-v2.html")]
1919
[NativeHeader("Editor/Src/2D/SpriteAtlas/SpriteAtlasImporter.h")]
2020
public sealed partial class SpriteAtlasImporter : AssetImporter
2121
{

Editor/Mono/Animation/AnimationWindow/CurveEditorWindow.cs

+27-11
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@ public enum NormalizationMode
3030
}
3131

3232
//const int kToolbarHeight = 17;
33-
const int kPresetsHeight = 46;
33+
const int kPresetsHeight = 50;
3434

3535
static CurveEditorWindow s_SharedCurveEditor;
3636

3737
internal CurveEditor m_CurveEditor;
3838

39+
Vector2 m_PresetScrollPosition;
3940
AnimationCurve m_Curve;
4041
Color m_Color;
4142

@@ -476,20 +477,38 @@ void OnGUI()
476477
m_CurveEditor.OnGUI();
477478

478479
// Preset swatch area
479-
GUI.Box(new Rect(0, position.height - kPresetsHeight, position.width, kPresetsHeight), "", ms_Styles.curveSwatchArea);
480+
var presetRect = new Rect(0, position.height - kPresetsHeight, position.width, kPresetsHeight);
481+
GUI.Box(presetRect, "", ms_Styles.curveSwatchArea);
482+
480483
Color curveColor = m_Color;
481484
curveColor.a *= 0.6f;
482-
const float margin = 45f;
483485
const float width = 40f;
484486
const float height = 25f;
485-
float yPos = position.height - kPresetsHeight + (kPresetsHeight - height) * 0.5f;
487+
const float spaceBetweenSwatches = 5f;
488+
const float presetDropdownSize = 16f;
489+
const float horizontalScrollbarHeight = 15f;
490+
const float presetDropdownCenteringOffset = 2f;
491+
float yPos = (kPresetsHeight - height) * 0.5f;
486492
InitCurvePresets();
487493
CurvePresetLibrary curveLibrary = m_CurvePresets.GetPresetLibraryEditor().GetCurrentLib();
488494
if (curveLibrary != null)
489495
{
490-
for (int i = 0; i < curveLibrary.Count(); i++)
496+
var numPresets = curveLibrary.Count();
497+
var presetDropDownRect = new Rect(spaceBetweenSwatches, yPos + presetDropdownCenteringOffset, presetDropdownSize, presetDropdownSize);
498+
Rect contentRect = new Rect(0, 0, numPresets * (width + spaceBetweenSwatches) + presetDropDownRect.xMax, presetRect.height - horizontalScrollbarHeight);
499+
m_PresetScrollPosition = GUI.BeginScrollView(
500+
presetRect, // Rectangle of the visible area
501+
m_PresetScrollPosition, // Current scroll position
502+
contentRect, // Rectangle containing all content
503+
false, // Always show horizontal scrollbar
504+
false // Always show vertical scrollbar
505+
);
506+
507+
PresetDropDown(presetDropDownRect);
508+
509+
Rect swatchRect = new Rect(presetDropDownRect.xMax + spaceBetweenSwatches, yPos, width, height);
510+
for (int i = 0; i < numPresets; i++)
491511
{
492-
Rect swatchRect = new Rect(margin + (width + 5f) * i, yPos, width, height);
493512
m_GUIContent.tooltip = curveLibrary.GetName(i);
494513
if (GUI.Button(swatchRect, m_GUIContent, ms_Styles.curveSwatch))
495514
{
@@ -503,14 +522,11 @@ void OnGUI()
503522
if (Event.current.type == EventType.Repaint)
504523
curveLibrary.Draw(swatchRect, i);
505524

506-
if (swatchRect.xMax > position.width - 2 * margin)
507-
break;
525+
swatchRect.x += width + spaceBetweenSwatches;
508526
}
527+
GUI.EndScrollView();
509528
}
510529

511-
Rect presetDropDownButtonRect = new Rect(margin - 20f, yPos + 5f, 20, 20);
512-
PresetDropDown(presetDropDownButtonRect);
513-
514530
// For adding default preset curves
515531
//if (EditorGUI.DropdownButton(new Rect (position.width -26, yPos, 20, 20), GUIContent.none, FocusType.Passive, "OL Plus"))
516532
// AddDefaultPresetsToCurrentLib ();

Editor/Mono/Annotation/AnnotationWindow.cs

+1
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ private void IconHasChanged()
230230
}
231231
}
232232
}
233+
SyncToState();
233234

234235
Repaint();
235236
}

Editor/Mono/Annotation/SceneRenderModeWindow.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ static class Styles
146146

147147
}
148148

149-
// Default CameraMode should be DrawCameraMode.GIContributorsReceivers
149+
// UUM-96180: Default CameraMode should be DrawCameraMode.GIContributorsReceivers
150150
internal static SceneView.CameraMode defaultCameraMode
151151
{
152152
get

Editor/Mono/AssemblyInfo/AssemblyInfo.cs

+1
Original file line numberDiff line numberDiff line change
@@ -203,4 +203,5 @@
203203
// This should move with the AnimationWindow to a module at some point
204204
[assembly: InternalsVisibleTo("Unity.Modules.Animation.AnimationWindow.Tests.Editor")]
205205
[assembly: InternalsVisibleTo("Unity.Modules.Physics.Tests.Editor")]
206+
[assembly: InternalsVisibleTo("Unity.Tests.Shared")]
206207

Editor/Mono/BuildPipeline.bindings.cs

+3
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,9 @@ public static string GetPlaybackEngineDirectory(BuildTargetGroup buildTargetGrou
703703
[FreeFunction(IsThreadSafe = true)]
704704
public static extern string GetPlaybackEngineDirectory(BuildTargetGroup buildTargetGroup, BuildTarget target, BuildOptions options, bool assertUnsupportedPlatforms);
705705

706+
[FreeFunction]
707+
internal static extern bool IsServerBuildPlatformSupported(BuildTarget target);
708+
706709
internal static string GetBuildToolsDirectory(BuildTarget target)
707710
{
708711
return Path.Combine(GetPlaybackEngineDirectory(target, BuildOptions.None, false), "Tools");

Editor/Mono/BuildPlayerWindowBuildMethods.cs

+24-3
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,15 @@ public static void BuildPlayer(BuildPlayerOptions options)
176176
if (report != null
177177
)
178178
{
179-
var resultStr = String.Format("Build completed with a result of '{0}' in {1} seconds ({2} ms)",
179+
var resultStr = String.Format("Build completed with a result of '{0}' in {1} seconds ({2} ms) [{3} -> {4}, {5}]",
180180
report.summary.result.ToString("g"),
181181
Convert.ToInt32(report.summary.totalTime.TotalSeconds),
182-
Convert.ToInt32(report.summary.totalTime.TotalMilliseconds));
183-
182+
Convert.ToInt32(report.summary.totalTime.TotalMilliseconds),
183+
report.summary.buildStartedAt.ToLocalTime(),
184+
report.summary.buildEndedAt.ToLocalTime(),
185+
FriendlyFormatBuildDuration(report.summary.totalTime)
186+
);
187+
184188
switch (report.summary.result)
185189
{
186190
case Build.Reporting.BuildResult.Unknown:
@@ -202,6 +206,23 @@ public static void BuildPlayer(BuildPlayerOptions options)
202206
}
203207
}
204208

209+
static string FriendlyFormatBuildDuration(TimeSpan duration)
210+
{
211+
int totalHours = (int)duration.TotalHours;
212+
213+
if (totalHours > 0)
214+
{
215+
return string.Format("{0}h {1:D2}m {2:D2}s", totalHours, duration.Minutes, duration.Seconds);
216+
}
217+
218+
if (duration.Minutes > 0)
219+
{
220+
return string.Format("{0}m {1:D2}s", duration.Minutes, duration.Seconds);
221+
}
222+
223+
return string.Format("{0:D2}s", duration.Seconds);
224+
}
225+
205226
/// <summary>
206227
/// Default implementation for calculating build options before building the player.
207228
/// </summary>

Editor/Mono/BuildProfile/BuildProfileContext.cs

+22-6
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,7 @@ internal static BuildProfile activeProfile
6666
{
6767
get
6868
{
69-
// Active Build profile may be deleted from the project.
70-
var activeProfile = EditorUserBuildSettings.activeBuildProfile;
71-
if (activeProfile != null && activeProfile.CanBuildLocally())
72-
return activeProfile;
73-
74-
return null;
69+
return EditorUserBuildSettings.activeBuildProfile;
7570
}
7671

7772
set
@@ -275,6 +270,27 @@ internal static BuildProfile GetActiveOrClassicBuildProfile(
275270
return IsSharedProfile(platformGuid) ? instance.sharedProfile : instance.GetForClassicPlatform(platformGuid);
276271
}
277272

273+
/// <summary>
274+
/// This method allows the native code to fetch the development setting from
275+
/// build profiles without allocations.
276+
/// </summary>
277+
/// <remarks>
278+
/// This is a workaround for certain allocation-sensitive graphics tests to pass.
279+
/// We use return by ref to avoid the allocation that occurs when the return value
280+
/// is boxed into a ScriptingObjectPtr.
281+
/// </remarks>
282+
[RequiredByNativeCode]
283+
internal static void GetActiveOrClassicBuildProfileDevelopmentSetting(ref bool value)
284+
{
285+
var profile = IsSharedSettingEnabledInActiveProfile("development") ?
286+
activeProfile : instance.sharedProfile;
287+
288+
if (profile == null || profile.platformBuildProfile == null)
289+
value = false;
290+
else
291+
value = profile.platformBuildProfile.development;
292+
}
293+
278294
internal static bool TryGetActiveOrClassicPlatformSettingsBase<T>(
279295
BuildTarget target, StandaloneBuildSubtarget subTarget, out T result) where T : BuildProfilePlatformSettingsBase
280296
{

Editor/Mono/BuildTargetDiscovery.bindings.cs

+4-53
Original file line numberDiff line numberDiff line change
@@ -764,66 +764,17 @@ static void PreloadBuildPlatformInstalledData()
764764
}
765765

766766
bool isInstalled = false;
767-
if (platform.Value.HasFlag(PlatformAttributes.IsWindowsServerBuildTarget))
768-
{
769-
var serverVariations = new[]
770-
{
771-
"win32_server_development",
772-
"win32_server_nondevelopment",
773-
"win64_server_development",
774-
"win64_server_nondevelopment",
775-
"win_arm64_server_development",
776-
"win_arm64_server_nondevelopment",
777-
};
778-
isInstalled = VariationPresent(serverVariations, playbackEngineDirectory);
779-
}
780-
else if (platform.Value.HasFlag(PlatformAttributes.IsLinuxServerBuildTarget))
781-
{
782-
var serverVariations = new[]
783-
{
784-
"linux64_server_development",
785-
"linux64_server_nondevelopment",
786-
};
787-
isInstalled = VariationPresent(serverVariations, playbackEngineDirectory);
788-
}
789-
else if (platform.Value.HasFlag(PlatformAttributes.IsMacServerBuildTarget))
790-
{
791-
var serverVariations = new[]
792-
{
793-
"macos_x64_server_development",
794-
"macos_x64_server_nondevelopment",
795-
"macos_arm64_server_development",
796-
"macos_arm64_server_nondevelopment",
797-
"macos_x64arm64_server_development",
798-
"macos_x64arm64_server_nondevelopment",
799-
};
800-
isInstalled = VariationPresent(serverVariations, playbackEngineDirectory);
801-
}
767+
if (platform.Value.HasFlag(PlatformAttributes.IsWindowsServerBuildTarget) ||
768+
platform.Value.HasFlag(PlatformAttributes.IsLinuxServerBuildTarget) ||
769+
platform.Value.HasFlag(PlatformAttributes.IsMacServerBuildTarget))
770+
isInstalled = BuildPipeline.IsServerBuildPlatformSupported(platform.Value.buildTarget);
802771
else
803772
isInstalled = true;
804773

805774
k_PlatformInstalledData.Add(platform.Key, isInstalled);
806775
}
807776
}
808777

809-
static bool VariationPresent(string[] variations, string playbackEngineDirectory)
810-
{
811-
if (string.IsNullOrEmpty(playbackEngineDirectory))
812-
return false;
813-
814-
var scriptingBackends = new[] { "mono", "il2cpp", "coreclr" };
815-
foreach (var variation in variations)
816-
{
817-
foreach (var backend in scriptingBackends)
818-
{
819-
if (Directory.Exists(Paths.Combine(playbackEngineDirectory, "Variations", variation + "_" + backend)))
820-
return true;
821-
}
822-
}
823-
824-
return false;
825-
}
826-
827778
[System.Obsolete("BuildPlatformIsInstalled(BuildTarget) is obsolete. Use BuildPlatformIsInstalled(IBuildTarget) instead.", false)]
828779
public static bool BuildPlatformIsInstalled(BuildTarget platform) => BuildPlatformIsInstalled(GetGUIDFromBuildTarget(platform));
829780

Editor/Mono/EditorGraphicsSettings.bindings.cs

+11-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using UnityEditor.Rendering.Settings;
1010
using UnityEngine.Bindings;
1111
using UnityEngine.Rendering;
12+
using UnityEngine.Scripting;
1213
using Object = UnityEngine.Object;
1314

1415
namespace UnityEditor.Rendering
@@ -19,7 +20,7 @@ public sealed partial class EditorGraphicsSettings
1920
{
2021
[NativeName("SetTierSettings")] extern internal static void SetTierSettingsImpl(BuildTargetGroup target, GraphicsTier tier, TierSettings settings);
2122

22-
extern public static TierSettings GetTierSettings(BuildTargetGroup target, GraphicsTier tier);
23+
extern public static TierSettings GetTierSettings(BuildTargetGroup target, GraphicsTier tier);
2324
public static TierSettings GetTierSettings(NamedBuildTarget target, GraphicsTier tier) => GetTierSettings(target.ToBuildTargetGroup(), tier);
2425

2526
extern internal static TierSettings GetCurrentTierSettings();
@@ -34,7 +35,7 @@ public sealed partial class EditorGraphicsSettings
3435
extern internal static void RegisterUndo();
3536

3637
extern private static AlbedoSwatchInfo[] GetAlbedoSwatches();
37-
extern private static void SetAlbedoSwatches(AlbedoSwatchInfo[] swatches);
38+
extern private static void SetAlbedoSwatches(AlbedoSwatchInfo[] swatches);
3839

3940
public static AlbedoSwatchInfo[] albedoSwatches
4041
{
@@ -218,5 +219,13 @@ public static bool TryGetRenderPipelineSettingsFromInterfaceForPipeline<TSetting
218219

219220
return settings != null;
220221
}
222+
223+
[RequiredByNativeCode]
224+
internal static bool IsGlobalSettingsContaining(UnityEngine.Object renderPipelineGlobalSettings, object renderPipelineGraphicsSettings)
225+
{
226+
var settings = renderPipelineGraphicsSettings as IRenderPipelineGraphicsSettings;
227+
var globalSettings = renderPipelineGlobalSettings as RenderPipelineGlobalSettings;
228+
return globalSettings.ContainsReference(settings);
229+
}
221230
}
222231
}

Editor/Mono/EditorSettings.bindings.cs

+4
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,13 @@ public static string webSecurityEmulationHostUrl
173173
[StaticAccessor("GetEditorSettings()", StaticAccessorType.Dot)]
174174
internal static extern Bc7TextureCompressor bc7TextureCompressor { get; set; }
175175

176+
[Obsolete("EditorSettings.etcTextureCompressorBehavior has been deprecated with the removal of support for ETC Legacy compression behavior.", false)]
176177
[StaticAccessor("GetEditorSettings()", StaticAccessorType.Dot)]
177178
public static extern int etcTextureCompressorBehavior { get; set; }
178179

180+
[StaticAccessor("GetEditorSettings()", StaticAccessorType.Dot)]
181+
internal static extern int etcTextureCompressorBehaviorInternal { [NativeMethod("GetEtcTextureCompressorBehavior")] get; [NativeMethod("SetEtcTextureCompressorBehavior")] set; }
182+
179183
[StaticAccessor("GetEditorSettings()", StaticAccessorType.Dot)]
180184
public static extern int etcTextureFastCompressor {[NativeMethod("GetEtcTextureFastCompressorNoOffset")] get; set; }
181185

Editor/Mono/GUI/InternalEditorGUI.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ internal static void GameViewSizePopup(Rect buttonRect, GameViewSizeGroupType gr
305305
if (selectedIndex >= 0 && selectedIndex < group.GetTotalCount())
306306
text = group.GetGameViewSize(selectedIndex).displayText;
307307

308-
if (EditorGUI.DropdownButton(buttonRect, GUIContent.Temp(text), FocusType.Passive, guiStyle))
308+
if (DropdownButton(buttonRect, GUIContent.Temp(text, GameView.Styles.k_AspectRatioTooltip), FocusType.Passive, guiStyle))
309309
{
310310
var menuData = new GameViewSizesMenuItemProvider(groupType);
311311
var flexibleMenu = new GameViewSizeMenu(menuData, selectedIndex, new GameViewSizesMenuModifyItemUI(), gameView);

0 commit comments

Comments
 (0)