From eb55e2fbd25ef6e43cc8534849dc71f110cf5508 Mon Sep 17 00:00:00 2001 From: Unity Technologies Date: Tue, 28 Jan 2025 18:18:53 +0000 Subject: [PATCH 01/19] Unity 6000.1.0b4 C# reference source code --- Editor/Mono/Annotation/AnnotationWindow.cs | 3 +- .../Mono/Annotation/LayerVisibilityWindow.cs | 4 +- Editor/Mono/GUI/ColorPicker.cs | 222 ++++++++++++++++++ .../PresetLibraries/ColorPresetLibrary.cs | 2 +- .../DefaultLightingExplorerExtension.cs | 6 + .../BuildReportingEditor/Managed/BuildFile.cs | 6 + .../Managed/BuildReport.bindings.cs | 124 ++++++++++ .../Managed/BuildResult.cs | 5 + .../BuildReportingEditor/Managed/BuildStep.cs | 10 + .../Managed/BuildStepMessage.cs | 6 + .../Managed/BuildSummary.cs | 22 ++ .../BuildReportingEditor/Managed/BuildType.cs | 4 + .../Managed/CommonRoles.bindings.cs | 166 +++++++------ .../Managed/PackedAssetInfo.cs | 142 +++++++++++ .../Managed/PackedAssets.bindings.cs | 74 ++++++ .../Managed/ScenesUsingAsset.cs | 3 + .../Managed/ScenesUsingAssets.bindings.cs | 3 + .../Managed/StrippingInfo.cs | 9 + .../ToolbarElements/SnapSettings.cs | 1 + .../ScriptBindings/Physics2D.bindings.cs | 4 +- .../ShortcutHelperBarUtility.cs | 12 +- .../Managed/FontAssetCreatorWindow.cs | 4 +- .../Editor/Builder/Library/BuilderLibrary.cs | 1 - .../Builder/Library/BuilderLibraryTreeView.cs | 8 +- .../BuilderInPlaceTextEditingUtilities.cs | 16 +- .../Controllers/BaseTreeViewController.cs | 11 +- .../Core/Events/EventDispatchUtilities.cs | 7 - Modules/UIElements/Core/Events/MouseEvents.cs | 11 +- README.md | 2 +- Runtime/Export/Math/Color.cs | 4 +- 30 files changed, 784 insertions(+), 108 deletions(-) diff --git a/Editor/Mono/Annotation/AnnotationWindow.cs b/Editor/Mono/Annotation/AnnotationWindow.cs index 7e544715ec..15106181b3 100644 --- a/Editor/Mono/Annotation/AnnotationWindow.cs +++ b/Editor/Mono/Annotation/AnnotationWindow.cs @@ -56,7 +56,6 @@ private enum EnabledState const float k_WindowWidth = 270; const float k_ScrollBarWidth = 14; const float k_ListElementHeight = 18; - const float k_JustClosedPeriod = 200; const float k_FrameWidth = 1f; float iconSize = 16; float gizmoRightAlign; @@ -66,6 +65,8 @@ private enum EnabledState static AnnotationWindow s_AnnotationWindow = null; static long s_LastClosedTime; + const long k_JustClosedPeriod = 400; + static Styles m_Styles; List m_RecentAnnotations; List m_BuiltinAnnotations; diff --git a/Editor/Mono/Annotation/LayerVisibilityWindow.cs b/Editor/Mono/Annotation/LayerVisibilityWindow.cs index 0fe1e241aa..177ad6e7cd 100644 --- a/Editor/Mono/Annotation/LayerVisibilityWindow.cs +++ b/Editor/Mono/Annotation/LayerVisibilityWindow.cs @@ -39,14 +39,14 @@ public Styles() const float k_FrameWidth = 1f; const float k_ToggleSize = 17; const float k_SeparatorHeight = 6; - const float k_JustClosedPeriod = 200; const string k_LayerVisible = "Show/Hide Layer"; const string k_LayerPickable = "Toggle Pickable status this Layer. Non-Pickable items cannot be selected in the Scene View."; private static LayerVisibilityWindow s_LayerVisibilityWindow; private static long s_LastClosedTime; - private static Styles s_Styles; + const long k_JustClosedPeriod = 400; + private static Styles s_Styles; private List s_LayerNames; private List s_LayerMasks; private int m_AllLayersMask; diff --git a/Editor/Mono/GUI/ColorPicker.cs b/Editor/Mono/GUI/ColorPicker.cs index ff63053f6c..24664b9e8c 100644 --- a/Editor/Mono/GUI/ColorPicker.cs +++ b/Editor/Mono/GUI/ColorPicker.cs @@ -12,6 +12,7 @@ namespace UnityEditor internal class ColorPicker : EditorWindow { private const string k_HeightPrefKey = "CPickerHeight"; + private const string k_ShowDefaultsPrefKey = "CPDefaultsShow"; private const string k_ShowPresetsPrefKey = "CPPresetsShow"; // HDR and LDR have different slider mode pref keys because they have different defaults for the sake of discoverability private const string k_SliderModePrefKey = "CPSliderMode"; @@ -40,6 +41,8 @@ internal class ColorPicker : EditorWindow Texture2D m_ColorBox; static int s_Slider2Dhash = "Slider2D".GetHashCode(); [SerializeField] + bool m_ShowDefaults = true; + [SerializeField] bool m_ShowPresets = true; [SerializeField] @@ -482,6 +485,7 @@ static class Styles public static readonly GUIContent exposureValue = EditorGUIUtility.TrTextContent("Intensity", "Number of stops to over- or under-expose the color. The intensity calculates each time based on the predefined max color component of 191 (0.749) when Color Picker opens."); public static readonly GUIContent hexLabel = EditorGUIUtility.TrTextContent("Hexadecimal"); public static readonly GUIContent presetsToggle = EditorGUIUtility.TrTextContent("Swatches"); + public static readonly GUIContent defaultsToggle = EditorGUIUtility.TrTextContent("Defaults"); public static readonly ScalableGUIContent originalColorSwatchFill = new ScalableGUIContent(string.Empty, "The original color. Click this swatch to reset the color picker to this value.", "ColorPicker-OriginalColor"); @@ -877,6 +881,218 @@ void DoExposureSwatches() GUI.contentColor = contentColor; } + // used in TestColorPicker.OpeningColorPicker_InitialisesCorrectDefaultColors + internal static (Color, string)[] TESTdefaultColors => instance?.m_DefaultColors; + readonly (Color, string)[] m_DefaultColors = new (Color, string)[] + { + (Color.red, nameof(Color.red)), + (Color.green, nameof(Color.green)), + (Color.blue, nameof(Color.blue)), + (Color.yellow, nameof(Color.yellow)), + (Color.cyan, nameof(Color.cyan)), + (Color.magenta, nameof(Color.magenta)), + (Color.gray1, nameof(Color.gray1)), + (Color.gray2, nameof(Color.gray2)), + (Color.gray3, nameof(Color.gray3)), + (Color.gray4, nameof(Color.gray4)), + (Color.gray5, nameof(Color.gray5)), + (Color.gray6, nameof(Color.gray6)), + (Color.gray7, nameof(Color.gray7)), + (Color.gray8, nameof(Color.gray8)), + (Color.gray9, nameof(Color.gray9)), + (Color.white, nameof(Color.white)), + (Color.whiteSmoke, nameof(Color.whiteSmoke)), + (Color.gainsboro, nameof(Color.gainsboro)), + (Color.lightGray, nameof(Color.lightGray)), + (Color.silver, nameof(Color.silver)), + (Color.darkGray, nameof(Color.darkGray)), + (Color.dimGray, nameof(Color.dimGray)), + (Color.black, nameof(Color.black)), + (Color.darkRed, nameof(Color.darkRed)), + (Color.brown, nameof(Color.brown)), + (Color.firebrick, nameof(Color.firebrick)), + (Color.crimson, nameof(Color.crimson)), + (Color.softRed, nameof(Color.softRed)), + (Color.indianRed, nameof(Color.indianRed)), + (Color.violetRed, nameof(Color.violetRed)), + (Color.mediumVioletRed, nameof(Color.mediumVioletRed)), + (Color.deepPink, nameof(Color.deepPink)), + (Color.hotPink, nameof(Color.hotPink)), + (Color.lightPink, nameof(Color.lightPink)), + (Color.pink, nameof(Color.pink)), + (Color.paleVioletRed, nameof(Color.paleVioletRed)), + (Color.maroon, nameof(Color.maroon)), + (Color.rosyBrown, nameof(Color.rosyBrown)), + (Color.lightCoral, nameof(Color.lightCoral)), + (Color.salmon, nameof(Color.salmon)), + (Color.tomato, nameof(Color.tomato)), + (Color.darkSalmon, nameof(Color.darkSalmon)), + (Color.coral, nameof(Color.coral)), + (Color.orangeRed, nameof(Color.orangeRed)), + (Color.lightSalmon, nameof(Color.lightSalmon)), + (Color.sienna, nameof(Color.sienna)), + (Color.saddleBrown, nameof(Color.saddleBrown)), + (Color.chocolate, nameof(Color.chocolate)), + (Color.sandyBrown, nameof(Color.sandyBrown)), + (Color.peru, nameof(Color.peru)), + (Color.darkOrange, nameof(Color.darkOrange)), + (Color.burlywood, nameof(Color.burlywood)), + (Color.tan, nameof(Color.tan)), + (Color.moccasin, nameof(Color.moccasin)), + (Color.peachPuff, nameof(Color.peachPuff)), + (Color.bisque, nameof(Color.bisque)), + (Color.navajoWhite, nameof(Color.navajoWhite)), + (Color.wheat, nameof(Color.wheat)), + (Color.orange, nameof(Color.orange)), + (Color.darkGoldenRod, nameof(Color.darkGoldenRod)), + (Color.goldenRod, nameof(Color.goldenRod)), + (Color.lightGoldenRod, nameof(Color.lightGoldenRod)), + (Color.gold, nameof(Color.gold)), + (Color.softYellow, nameof(Color.softYellow)), + (Color.lightGoldenRodYellow, nameof(Color.lightGoldenRodYellow)), + (Color.beige, nameof(Color.beige)), + (Color.lemonChiffon, nameof(Color.lemonChiffon)), + (Color.lightYellow, nameof(Color.lightYellow)), + (Color.yellowNice, nameof(Color.yellowNice)), + (Color.khaki, nameof(Color.khaki)), + (Color.paleGoldenRod, nameof(Color.paleGoldenRod)), + (Color.darkKhaki, nameof(Color.darkKhaki)), + (Color.olive, nameof(Color.olive)), + (Color.oliveDrab, nameof(Color.oliveDrab)), + (Color.yellowGreen, nameof(Color.yellowGreen)), + (Color.darkOliveGreen, nameof(Color.darkOliveGreen)), + (Color.softGreen, nameof(Color.softGreen)), + (Color.greenYellow, nameof(Color.greenYellow)), + (Color.chartreuse, nameof(Color.chartreuse)), + (Color.lawnGreen, nameof(Color.lawnGreen)), + (Color.darkGreen, nameof(Color.darkGreen)), + (Color.forestGreen, nameof(Color.forestGreen)), + (Color.limeGreen, nameof(Color.limeGreen)), + (Color.darkSeaGreen, nameof(Color.darkSeaGreen)), + (Color.lightGreen, nameof(Color.lightGreen)), + (Color.paleGreen, nameof(Color.paleGreen)), + (Color.seaGreen, nameof(Color.seaGreen)), + (Color.mediumSeaGreen, nameof(Color.mediumSeaGreen)), + (Color.springGreen, nameof(Color.springGreen)), + (Color.mediumSpringGreen, nameof(Color.mediumSpringGreen)), + (Color.aquamarine, nameof(Color.aquamarine)), + (Color.mediumAquamarine, nameof(Color.mediumAquamarine)), + (Color.turquoise, nameof(Color.turquoise)), + (Color.mediumTurquoise, nameof(Color.mediumTurquoise)), + (Color.lightSeaGreen, nameof(Color.lightSeaGreen)), + (Color.lightSlateGray, nameof(Color.lightSlateGray)), + (Color.slateGray, nameof(Color.slateGray)), + (Color.darkSlateGray, nameof(Color.darkSlateGray)), + (Color.teal, nameof(Color.teal)), + (Color.darkCyan, nameof(Color.darkCyan)), + (Color.lightCyan, nameof(Color.lightCyan)), + (Color.mintCream, nameof(Color.mintCream)), + (Color.honeydew, nameof(Color.honeydew)), + (Color.azure, nameof(Color.azure)), + (Color.paleTurquoise, nameof(Color.paleTurquoise)), + (Color.darkTurquoise, nameof(Color.darkTurquoise)), + (Color.cadetBlue, nameof(Color.cadetBlue)), + (Color.powderBlue, nameof(Color.powderBlue)), + (Color.softBlue, nameof(Color.softBlue)), + (Color.lightBlue, nameof(Color.lightBlue)), + (Color.deepSkyBlue, nameof(Color.deepSkyBlue)), + (Color.skyBlue, nameof(Color.skyBlue)), + (Color.lightSkyBlue, nameof(Color.lightSkyBlue)), + (Color.steelBlue, nameof(Color.steelBlue)), + (Color.dodgerBlue, nameof(Color.dodgerBlue)), + (Color.lightSteelBlue, nameof(Color.lightSteelBlue)), + (Color.ghostWhite, nameof(Color.ghostWhite)), + (Color.aliceBlue, nameof(Color.aliceBlue)), + (Color.lavender, nameof(Color.lavender)), + (Color.cornflowerBlue, nameof(Color.cornflowerBlue)), + (Color.royalBlue, nameof(Color.royalBlue)), + (Color.navyBlue, nameof(Color.navyBlue)), + (Color.midnightBlue, nameof(Color.midnightBlue)), + (Color.darkBlue, nameof(Color.darkBlue)), + (Color.mediumBlue, nameof(Color.mediumBlue)), + (Color.slateBlue, nameof(Color.slateBlue)), + (Color.lightSlateBlue, nameof(Color.lightSlateBlue)), + (Color.mediumSlateBlue, nameof(Color.mediumSlateBlue)), + (Color.darkSlateBlue, nameof(Color.darkSlateBlue)), + (Color.mediumPurple, nameof(Color.mediumPurple)), + (Color.rebeccaPurple, nameof(Color.rebeccaPurple)), + (Color.blueViolet, nameof(Color.blueViolet)), + (Color.indigo, nameof(Color.indigo)), + (Color.purple, nameof(Color.purple)), + (Color.darkOrchid, nameof(Color.darkOrchid)), + (Color.darkViolet, nameof(Color.darkViolet)), + (Color.mediumOrchid, nameof(Color.mediumOrchid)), + (Color.darkMagenta, nameof(Color.darkMagenta)), + (Color.violet, nameof(Color.violet)), + (Color.plum, nameof(Color.plum)), + (Color.thistle, nameof(Color.thistle)), + (Color.orchid, nameof(Color.orchid)), + (Color.lavenderBlush, nameof(Color.lavenderBlush)), + (Color.seashell, nameof(Color.seashell)), + (Color.blanchedAlmond, nameof(Color.blanchedAlmond)), + (Color.papayaWhip, nameof(Color.papayaWhip)), + (Color.cornsilk, nameof(Color.cornsilk)), + (Color.ivory, nameof(Color.ivory)), + (Color.linen, nameof(Color.linen)), + (Color.floralWhite, nameof(Color.floralWhite)), + (Color.antiqueWhite, nameof(Color.antiqueWhite)), + (Color.oldLace, nameof(Color.oldLace)), + (Color.mistyRose, nameof(Color.mistyRose)), + (Color.snow, nameof(Color.snow)), + }; + + Texture2D m_SwatchTex; + void DoDefaultsGUI() + { + if (m_SwatchTex == null) m_SwatchTex = ColorPresetLibrary.CreateColorSwatchWithBorder(14, 14, false); + + m_ShowDefaults = EditorGUILayout.Foldout(m_ShowDefaults, Styles.defaultsToggle, true); + + if (m_ShowDefaults) + { + using (new EditorGUILayout.VerticalScope()) + { + EditorGUILayout.BeginHorizontal(); + for (int i = 0; i < m_DefaultColors.Length; ++i) + { + var (color, name) = m_DefaultColors[i]; + if (i != 0 && i % 15 == 0) + { + GUILayout.FlexibleSpace(); + EditorGUILayout.EndHorizontal(); + EditorGUILayout.BeginHorizontal(); + } + + using (new GUI.ColorScope(color)) + { + string tooltip; + if (m_SliderMode == SliderMode.HSV) + { + Color.RGBToHSV(color, out var h, out var s, out var v); + tooltip = $"{name} HSVA({Mathf.RoundToInt(h * 360)}, {Mathf.RoundToInt(s * 100)}, {Mathf.RoundToInt(v * 100)}, {Mathf.RoundToInt(color.a * 100)})"; + } + else if (m_SliderMode == SliderMode.RGB) + { + tooltip = $"{name} {(Color32)color}";; + } + else + tooltip = $"{name} {color}"; + + var clicked = GUILayout.Button( + new GUIContent(m_SwatchTex, tooltip), + GUIStyle.none, + new GUILayoutOption(GUILayoutOption.Type.fixedWidth, 14f)); + + if (clicked) + SetColor(color); + } + } + GUILayout.FlexibleSpace(); + EditorGUILayout.EndHorizontal(); + } + } + } + void DoPresetsGUI() { var foldoutRect = GUILayoutUtility.GetRect(Styles.presetsToggle, EditorStyles.foldout); @@ -953,6 +1169,8 @@ void OnGUI() GUILayout.Space(Styles.extraVerticalSpacing); } + DoDefaultsGUI(); + DoPresetsGUI(); // Call last to ensure we only use the copy paste events if no @@ -1177,11 +1395,13 @@ void OnEnable() m_SliderMode = (SliderMode)EditorPrefs.GetInt(k_SliderModePrefKey, (int)SliderMode.RGB); m_ShowPresets = EditorPrefs.GetInt(k_ShowPresetsPrefKey, 1) != 0; + m_ShowDefaults = EditorPrefs.GetInt(k_ShowDefaultsPrefKey, 1) != 0; } void OnDisable() { EditorPrefs.SetInt(m_HDR ? k_SliderModeHDRPrefKey : k_SliderModePrefKey, (int)m_SliderMode); + EditorPrefs.SetInt(k_ShowDefaultsPrefKey, m_ShowDefaults ? 1 : 0); EditorPrefs.SetInt(k_ShowPresetsPrefKey, m_ShowPresets ? 1 : 0); EditorPrefs.SetInt(k_HeightPrefKey, (int)position.height); } @@ -1208,6 +1428,8 @@ public void OnDestroy() DestroyImmediate(m_ValTexture); if (m_AlphaTexture) DestroyImmediate(m_AlphaTexture); + if (m_SwatchTex) + DestroyImmediate(m_SwatchTex); s_Instance = null; if (m_ColorLibraryEditorState != null) diff --git a/Editor/Mono/PresetLibraries/ColorPresetLibrary.cs b/Editor/Mono/PresetLibraries/ColorPresetLibrary.cs index f5124598e6..ced8fa9ca6 100644 --- a/Editor/Mono/PresetLibraries/ColorPresetLibrary.cs +++ b/Editor/Mono/PresetLibraries/ColorPresetLibrary.cs @@ -161,7 +161,7 @@ public void CreateDebugColors() m_Presets.Add(new ColorPreset(new Color(Random.Range(0.2f, 1f), Random.Range(0.2f, 1f), Random.Range(0.2f, 1f), 1f), "Preset Color " + i)); } - private static Texture2D CreateColorSwatchWithBorder(int width, int height, bool triangular) + internal static Texture2D CreateColorSwatchWithBorder(int width, int height, bool triangular) { Texture2D texture = new Texture2D(width, height, TextureFormat.RGBA32, false); texture.hideFlags = HideFlags.HideAndDontSave; diff --git a/Editor/Mono/SceneModeWindows/DefaultLightingExplorerExtension.cs b/Editor/Mono/SceneModeWindows/DefaultLightingExplorerExtension.cs index 3f1cfe4372..3a91253d36 100644 --- a/Editor/Mono/SceneModeWindows/DefaultLightingExplorerExtension.cs +++ b/Editor/Mono/SceneModeWindows/DefaultLightingExplorerExtension.cs @@ -471,7 +471,9 @@ protected virtual LightingExplorerTableColumn[] GetEmissivesColumns() if (EditorGUI.EndChangeCheck()) { Material material = (Material)prop.serializedObject.targetObject; + Undo.RecordObject(material, $"Modify Emission Flags of {material.name}"); material.globalIlluminationFlags = giFlags; + EditorUtility.SetDirty(material); prop.serializedObject.Update(); } @@ -495,7 +497,9 @@ protected virtual LightingExplorerTableColumn[] GetEmissivesColumns() if (EditorGUI.EndChangeCheck()) { + Undo.RecordObject(material, $"Modify Emission Flags of {material.name}"); material.SetColor("_EmissionColor", newValue); + EditorUtility.SetDirty(material); } EditorGUI.EndProperty(); } @@ -511,7 +515,9 @@ protected virtual LightingExplorerTableColumn[] GetEmissivesColumns() Color color = sourceMaterial.GetColor("_EmissionColor"); Material targetMaterial = (Material)target.serializedObject.targetObject; + Undo.RecordObject(targetMaterial, $"Modify Emission Flags of {targetMaterial.name}"); targetMaterial.SetColor("_EmissionColor", color); + EditorUtility.SetDirty(targetMaterial); }) // 3: Color }; } diff --git a/Modules/BuildReportingEditor/Managed/BuildFile.cs b/Modules/BuildReportingEditor/Managed/BuildFile.cs index 673cf09cae..4bb8ca7ec8 100644 --- a/Modules/BuildReportingEditor/Managed/BuildFile.cs +++ b/Modules/BuildReportingEditor/Managed/BuildFile.cs @@ -7,13 +7,19 @@ namespace UnityEditor.Build.Reporting { + ///Contains information about a single file produced by the build process. [NativeType(Header = "Modules/BuildReportingEditor/Public/BuildReport.h")] public struct BuildFile { + ///The unique indentifier of the build file. public uint id { get; } + ///The absolute path of the file produced by the build process. public string path { get; } + ///The role the file plays in the build output. + ///Use this field to understand what purpose a file serves within the built player. Common roles for files are captured by the members of the class. public string role { get; } + ///The total size of the file, in bytes. [NativeName("totalSize")] public ulong size { get; } diff --git a/Modules/BuildReportingEditor/Managed/BuildReport.bindings.cs b/Modules/BuildReportingEditor/Managed/BuildReport.bindings.cs index 532be3e47f..5a53cf8c6a 100644 --- a/Modules/BuildReportingEditor/Managed/BuildReport.bindings.cs +++ b/Modules/BuildReportingEditor/Managed/BuildReport.bindings.cs @@ -10,6 +10,110 @@ namespace UnityEditor.Build.Reporting { + ///The BuildReport API gives you information about the Unity build process. + ///A BuildReport object is returned by and can be used to discover information about the files output, the build steps taken, and other platform-specific information such as native code stripping. + /// + ///For AssetBundle builds the BuildReport is available by calling immediately after calling . + /// + /// s.name.Length + s.depth) + 3; + /// foreach (var step in buildReport.steps) + /// { + /// string rawStepOutput = new string('-', step.depth + 1) + ' ' + step.name; + /// sb.AppendLine($"{rawStepOutput.PadRight(maxWidth)}: {step.duration:g}"); + /// } + /// return sb.ToString(); + /// } + /// + /// public static string LogBuildMessages(BuildReport buildReport) + /// { + /// var sb = new StringBuilder(); + /// foreach (var step in buildReport.steps) + /// { + /// foreach (var message in step.messages) + /// // If desired, this logic could ignore any Info or Warning messages to focus on more serious messages + /// sb.AppendLine($"[{message.type}] {message.content}"); + /// } + /// + /// string messages = sb.ToString(); + /// if (messages.Length > 0) + /// return "Messages logged during Build:\n" + messages; + /// else + /// return ""; + /// } + ///} + /// + /// // For the purpose of demonstration, this callback logs different types of errors and forces a build failure + ///[BuildCallbackVersion(1)] + ///class MyTroublesomeBuildCallback : IProcessSceneWithReport + ///{ + /// public int callbackOrder { get { return 0; } } + /// public void OnProcessScene(UnityEngine.SceneManagement.Scene scene, BuildReport report) + /// { + /// Debug.Log("MyTroublesomeBuildCallback called for " + scene.name); + /// Debug.LogError("Logging an error"); + /// + /// throw new BuildFailedException("Forcing the build to stop"); + /// } + ///} + ///]]> + /// [NativeHeader("Runtime/Utilities/DateTime.h")] [NativeType(Header = "Modules/BuildReportingEditor/Public/BuildReport.h")] [NativeClass("BuildReporting::BuildReport")] @@ -22,23 +126,34 @@ private BuildReport() [System.Obsolete("Use GetFiles() method instead (UnityUpgradable) -> GetFiles()", true)] public BuildFile[] files => throw new NotSupportedException(); + ///Returns an array of all the files output by the build process. + ///The returned array is a copy and this method execution length scales linearly with number of files. + ///An array of all the files output by the build process. public extern BuildFile[] GetFiles(); + ///An array of all the s that took place during the build process. [NativeName("BuildSteps")] public extern BuildStep[] steps { get; } + ///A containing overall statistics and data about the build process. public extern BuildSummary summary { get; } + ///The object for the build. + ///The StrippingInfo object contains information about which native code modules in the engine are still present in the build, and the reasons why they are still present. + /// + ///This is only available when building for platforms that support code stripping. When building for other platforms, this property will be null. public StrippingInfo strippingInfo { get { return GetAppendices().SingleOrDefault(); } } + ///An array of all the generated by the build process. public PackedAssets[] packedAssets { get { return GetAppendicesByType(); } } + ///An optional array of generated by the build process if was used during the build. public ScenesUsingAssets[] scenesUsingAssets { get { return GetAppendicesByType(); } @@ -62,6 +177,12 @@ public ScenesUsingAssets[] scenesUsingAssets [NativeMethod("DeleteAllFiles")] internal extern void DeleteAllFileEntries(); + ///Returns a string summarizing any errors that occurred during the build + ///Convenience method for summarizing errors (or exceptions) that occurred during a build into a single line of text. + ///If no error was logged this returns an empty string. If a single error was logged this reports the error messages. Otherwise it reports the number of errors, for example "5 errors". + /// + ///Note: To examine all errors, warnings and other messages recorded during a build you can enumerating through the build and check . + ///And to retrieve the count of errors call . [FreeFunction("BuildReporting::SummarizeErrors", HasExplicitThis = true)] public extern string SummarizeErrors(); @@ -92,6 +213,9 @@ internal TAppendix[] GetAppendicesByType() where TAppendix : Object internal extern Object[] GetAllAppendices(); + ///Return the build report generated by the most recent Player or AssetBundle build + ///A BuildReport is generated when a Player build runs, or when is called. + ///The BuildReport is automatically saved to **Library/LastBuild.buildreport** and can be reloaded using this static method. [FreeFunction("BuildReporting::GetLatestReport")] public static extern BuildReport GetLatestReport(); diff --git a/Modules/BuildReportingEditor/Managed/BuildResult.cs b/Modules/BuildReportingEditor/Managed/BuildResult.cs index af40c6d732..22ce1e0814 100644 --- a/Modules/BuildReportingEditor/Managed/BuildResult.cs +++ b/Modules/BuildReportingEditor/Managed/BuildResult.cs @@ -6,11 +6,16 @@ namespace UnityEditor.Build.Reporting { + ///Describes the outcome of the build process. public enum BuildResult { + ///Indicates that the outcome of the build is in an unknown state. Unknown = 0, + ///Indicates that the build completed successfully. Succeeded = 1, + ///Indicates that the build failed. Failed = 2, + ///Indicates that the build was cancelled by the user. Cancelled = 3, } } diff --git a/Modules/BuildReportingEditor/Managed/BuildStep.cs b/Modules/BuildReportingEditor/Managed/BuildStep.cs index bd3cea5608..55159b3129 100644 --- a/Modules/BuildReportingEditor/Managed/BuildStep.cs +++ b/Modules/BuildReportingEditor/Managed/BuildStep.cs @@ -8,17 +8,27 @@ namespace UnityEditor.Build.Reporting { + ///Contains information about a single step in the build process. + /// + /// + /// [NativeType(Header = "Modules/BuildReportingEditor/Public/BuildReport.h")] public struct BuildStep { + ///The name of this build step. [NativeName("stepName")] public string name { get; } internal ulong durationTicks; + ///The total duration for this build step. public TimeSpan duration { get { return new TimeSpan((long)durationTicks); } } + ///All log messages recorded during this build step, in the order of which they occurred. + ///An array of structs. public BuildStepMessage[] messages { get; } + ///The nesting depth of the build step. + ///The build process is broken down into steps, and steps may themselves be broken down into sub-steps recursively. The nesting depth indicates how many higher-level build steps enclose this step. The step that represents the overall build process has depth 0, the sub-steps of that step have depth 1, and so on. public int depth { get; } public override string ToString() diff --git a/Modules/BuildReportingEditor/Managed/BuildStepMessage.cs b/Modules/BuildReportingEditor/Managed/BuildStepMessage.cs index b4fb96bc18..9d76dac554 100644 --- a/Modules/BuildReportingEditor/Managed/BuildStepMessage.cs +++ b/Modules/BuildReportingEditor/Managed/BuildStepMessage.cs @@ -9,10 +9,16 @@ namespace UnityEditor.Build.Reporting { + ///Contains information about a single log message recorded during the build process. + /// + /// + /// [NativeType(Header = "Modules/BuildReportingEditor/Public/BuildReport.h")] public struct BuildStepMessage { + ///The of the log message. public LogType type { get; } + ///The text content of the log message. public string content { get; } } } diff --git a/Modules/BuildReportingEditor/Managed/BuildSummary.cs b/Modules/BuildReportingEditor/Managed/BuildSummary.cs index fc803a89b7..85bf446535 100644 --- a/Modules/BuildReportingEditor/Managed/BuildSummary.cs +++ b/Modules/BuildReportingEditor/Managed/BuildSummary.cs @@ -7,35 +7,54 @@ namespace UnityEditor.Build.Reporting { + ///Contains overall summary information about a build. [NativeType(Header = "Modules/BuildReportingEditor/Managed/BuildSummary.bindings.h", CodegenOptions = CodegenOptions.Custom)] public struct BuildSummary { internal Int64 buildStartTimeTicks; + ///The time the build was started. public DateTime buildStartedAt { get { return new DateTime(buildStartTimeTicks); } } + ///The of the build. [NativeName("buildGUID")] public GUID guid { get; } + ///The platform that the build was created for. + ///See for possible values. public BuildTarget platform { get; } + ///The platform group the build was created for. + ///See for possible values. public BuildTargetGroup platformGroup { get; } internal int subtarget { get; } + ///The used for the build, as passed to . public BuildOptions options { get; } internal BuildAssetBundleOptions assetBundleOptions { get; } + ///The output path for the build, as provided to . public string outputPath { get; } internal uint crc { get; } + ///The total size of the build output, in bytes. public ulong totalSize { get; } internal UInt64 totalTimeTicks; + ///The total time taken by the build process. public TimeSpan totalTime { get { return new TimeSpan((long)totalTimeTicks); } } + ///The time the build ended. public DateTime buildEndedAt { get { return buildStartedAt + totalTime; } } + ///The total number of errors and exceptions recorded during the build process. public int totalErrors { get; } + ///The total number of warnings recorded during the build process. public int totalWarnings { get; } + ///The outcome of the build. + ///See for possible outcomes. [NativeName("buildResult")] public BuildResult result { get; } + ///The type of build. public BuildType buildType { get; } + ///Whether the multi-process option was enabled for the build. + /// public bool multiProcessEnabled { get; } private T ParseSubtarget() where T : Enum where S : Enum @@ -49,6 +68,9 @@ private T ParseSubtarget() where T : Enum where S : Enum return (T)(object)subtarget; } + ///The subtarget that the build was created for. + ///Valid values for type T are , and + ///Returns the subtarget value. public T GetSubtarget() where T : Enum { switch (platform) diff --git a/Modules/BuildReportingEditor/Managed/BuildType.cs b/Modules/BuildReportingEditor/Managed/BuildType.cs index 9f16d7d148..637d1e95ec 100644 --- a/Modules/BuildReportingEditor/Managed/BuildType.cs +++ b/Modules/BuildReportingEditor/Managed/BuildType.cs @@ -6,10 +6,14 @@ namespace UnityEditor.Build.Reporting { + ///Build type. + /// [Flags] public enum BuildType { + ///Indicates a Player build. Player = 1, + ///Indicates an Asset Bundle build. AssetBundle = 2 } } diff --git a/Modules/BuildReportingEditor/Managed/CommonRoles.bindings.cs b/Modules/BuildReportingEditor/Managed/CommonRoles.bindings.cs index 93584dcafc..4bbeec852a 100644 --- a/Modules/BuildReportingEditor/Managed/CommonRoles.bindings.cs +++ b/Modules/BuildReportingEditor/Managed/CommonRoles.bindings.cs @@ -4,78 +4,102 @@ using UnityEngine.Bindings; -namespace UnityEditor +namespace UnityEditor.Build.Reporting { - namespace Build.Reporting + ///This class provides constant values for some of the common roles used by files in the build. The role of each file in the build is available in . + [NativeType(Header = "Modules/BuildReportingEditor/Public/CommonRoles.h")] + public static class CommonRoles { - [NativeType(Header = "Modules/BuildReportingEditor/Public/CommonRoles.h")] - public static class CommonRoles - { - [NativeProperty("BuildReporting::CommonRoles::scene", true, TargetType.Field)] - public static extern string scene { get; } - - [NativeProperty("BuildReporting::CommonRoles::sharedAssets", true, TargetType.Field)] - public static extern string sharedAssets { get; } - - [NativeProperty("BuildReporting::CommonRoles::resourcesFile", true, TargetType.Field)] - public static extern string resourcesFile { get; } - - [NativeProperty("BuildReporting::CommonRoles::assetBundle", true, TargetType.Field)] - public static extern string assetBundle { get; } - - [NativeProperty("BuildReporting::CommonRoles::manifestAssetBundle", true, TargetType.Field)] - public static extern string manifestAssetBundle { get; } - - [NativeProperty("BuildReporting::CommonRoles::assetBundleTextManifest", true, TargetType.Field)] - public static extern string assetBundleTextManifest { get; } - - [NativeProperty("BuildReporting::CommonRoles::managedLibrary", true, TargetType.Field)] - public static extern string managedLibrary { get; } - - [NativeProperty("BuildReporting::CommonRoles::dependentManagedLibrary", true, TargetType.Field)] - public static extern string dependentManagedLibrary { get; } - - [NativeProperty("BuildReporting::CommonRoles::executable", true, TargetType.Field)] - public static extern string executable { get; } - - [NativeProperty("BuildReporting::CommonRoles::streamingResourceFile", true, TargetType.Field)] - public static extern string streamingResourceFile { get; } - - [NativeProperty("BuildReporting::CommonRoles::streamingAsset", true, TargetType.Field)] - public static extern string streamingAsset { get; } - - [NativeProperty("BuildReporting::CommonRoles::bootConfig", true, TargetType.Field)] - public static extern string bootConfig { get; } - - [NativeProperty("BuildReporting::CommonRoles::builtInResources", true, TargetType.Field)] - public static extern string builtInResources { get; } - - [NativeProperty("BuildReporting::CommonRoles::builtInShaders", true, TargetType.Field)] - public static extern string builtInShaders { get; } - - [NativeProperty("BuildReporting::CommonRoles::appInfo", true, TargetType.Field)] - public static extern string appInfo { get; } - - [NativeProperty("BuildReporting::CommonRoles::managedEngineAPI", true, TargetType.Field)] - public static extern string managedEngineApi { get; } - - [NativeProperty("BuildReporting::CommonRoles::monoRuntime", true, TargetType.Field)] - public static extern string monoRuntime { get; } - - [NativeProperty("BuildReporting::CommonRoles::monoConfig", true, TargetType.Field)] - public static extern string monoConfig { get; } - - [NativeProperty("BuildReporting::CommonRoles::debugInfo", true, TargetType.Field)] - public static extern string debugInfo { get; } - - [NativeProperty("BuildReporting::CommonRoles::globalGameManagers", true, TargetType.Field)] - public static extern string globalGameManagers { get; } - - [NativeProperty("BuildReporting::CommonRoles::crashHandler", true, TargetType.Field)] - public static extern string crashHandler { get; } - - [NativeProperty("BuildReporting::CommonRoles::engineLibrary", true, TargetType.Field)] - public static extern string engineLibrary { get; } - } + ///The value of a file that contains the packed content of a Scene. + [NativeProperty("BuildReporting::CommonRoles::scene", true, TargetType.Field)] + public static extern string scene { get; } + + ///The value of a file that contains asset objects which are shared between Scenes. Examples of asset objects are textures, models, and audio. + [NativeProperty("BuildReporting::CommonRoles::sharedAssets", true, TargetType.Field)] + public static extern string sharedAssets { get; } + + ///The value of the file that contains the contents of the project's "Resources" folder, packed into a single file. + [NativeProperty("BuildReporting::CommonRoles::resourcesFile", true, TargetType.Field)] + public static extern string resourcesFile { get; } + + ///The value of built AssetBundle files. + [NativeProperty("BuildReporting::CommonRoles::assetBundle", true, TargetType.Field)] + public static extern string assetBundle { get; } + + ///The value of a manifest AssetBundle, which is an AssetBundle that contains information about other AssetBundles and their dependencies. + [NativeProperty("BuildReporting::CommonRoles::manifestAssetBundle", true, TargetType.Field)] + public static extern string manifestAssetBundle { get; } + + ///The value of an AssetBundle manifest file, produced during the build process, that contains information about the bundle and its dependencies. + [NativeProperty("BuildReporting::CommonRoles::assetBundleTextManifest", true, TargetType.Field)] + public static extern string assetBundleTextManifest { get; } + + ///The value of a managed assembly, containing compiled script code. + [NativeProperty("BuildReporting::CommonRoles::managedLibrary", true, TargetType.Field)] + public static extern string managedLibrary { get; } + + ///The value of a managed library that is present in the build due to being a dependency of a . + [NativeProperty("BuildReporting::CommonRoles::dependentManagedLibrary", true, TargetType.Field)] + public static extern string dependentManagedLibrary { get; } + + ///The value of an executable - the file that will actually be launched on the target device. + [NativeProperty("BuildReporting::CommonRoles::executable", true, TargetType.Field)] + public static extern string executable { get; } + + ///The value of a file that contains streaming resource data. + ///For example, when a texture is packed into a build, only metadata about the texture is packed into the file - the actual content of the texture is packed into a streamingResourceFile, where it can be streamed into memory asynchronously at runtime. + [NativeProperty("BuildReporting::CommonRoles::streamingResourceFile", true, TargetType.Field)] + public static extern string streamingResourceFile { get; } + + ///The value of files that have been copied into the build without modification from the StreamingAssets folder in the project. + [NativeProperty("BuildReporting::CommonRoles::streamingAsset", true, TargetType.Field)] + public static extern string streamingAsset { get; } + + ///The value of the file that contains configuration information for the very early stages of engine startup. + [NativeProperty("BuildReporting::CommonRoles::bootConfig", true, TargetType.Field)] + public static extern string bootConfig { get; } + + ///The value of the file that contains built-in resources for the engine. + [NativeProperty("BuildReporting::CommonRoles::builtInResources", true, TargetType.Field)] + public static extern string builtInResources { get; } + + ///The value of the file that contains Unity's built-in shaders, such as the Standard shader. + [NativeProperty("BuildReporting::CommonRoles::builtInShaders", true, TargetType.Field)] + public static extern string builtInShaders { get; } + + ///The value of the file that provides config information used in Low Integrity mode on Windows. + [NativeProperty("BuildReporting::CommonRoles::appInfo", true, TargetType.Field)] + public static extern string appInfo { get; } + + ///The value of files that provide the managed API for Unity. + ///These files are referenced by your compiled script DLL and provide the interface layer between your scripts and the engine itself. + [NativeProperty("BuildReporting::CommonRoles::managedEngineAPI", true, TargetType.Field)] + public static extern string managedEngineApi { get; } + + ///The value of files that make up the Mono runtime itself. + [NativeProperty("BuildReporting::CommonRoles::monoRuntime", true, TargetType.Field)] + public static extern string monoRuntime { get; } + + ///The value of files that are used as configuration data by the Mono runtime. + [NativeProperty("BuildReporting::CommonRoles::monoConfig", true, TargetType.Field)] + public static extern string monoConfig { get; } + + ///The value of files that contain information for debuggers. + ///These files include debug information, such as symbols, for both managed assemblies and native executables and libraries. + [NativeProperty("BuildReporting::CommonRoles::debugInfo", true, TargetType.Field)] + public static extern string debugInfo { get; } + + ///The value of the file that contains global Project Settings data for the player. + [NativeProperty("BuildReporting::CommonRoles::globalGameManagers", true, TargetType.Field)] + public static extern string globalGameManagers { get; } + + ///The value of the executable that is used to capture crashes from the player. + [NativeProperty("BuildReporting::CommonRoles::crashHandler", true, TargetType.Field)] + public static extern string crashHandler { get; } + + ///The value of the main Unity runtime when it is built as a separate library. + ///On most platforms, the Unity runtime is also the main executable for the player, but on some platforms it is split into a separate file, allowing the main executable to be smaller and more easily customized. + [NativeProperty("BuildReporting::CommonRoles::engineLibrary", true, TargetType.Field)] + public static extern string engineLibrary { get; } } } diff --git a/Modules/BuildReportingEditor/Managed/PackedAssetInfo.cs b/Modules/BuildReportingEditor/Managed/PackedAssetInfo.cs index 843f2a5b33..3b971812f4 100644 --- a/Modules/BuildReportingEditor/Managed/PackedAssetInfo.cs +++ b/Modules/BuildReportingEditor/Managed/PackedAssetInfo.cs @@ -7,15 +7,157 @@ namespace UnityEditor.Build.Reporting { + ///Contains information about a range of bytes in a file in the build output. + ///A Packed Asset contains either the serialized binary representation of a Unity Object, + ///or the binary data of a texture, mesh, audio or video that belongs to a Unity object. + /// + ///Note: the "Packed Asset" name is somewhat misleading because the data is associated with a specific object within an Asset, not an entire Asset. + ///Some Assets contain just a single object, but in many cases it may contain an entire hierarchy of objects, each with its own PackedAssetInfo entry. + /// + /// (); + /// + /// var packedAssets = buildReport.packedAssets; + /// foreach(var packedAsset in packedAssets) + /// { + /// sb.AppendLine("Analyzing " + packedAsset.shortPath + "...."); + /// + /// var contents = packedAsset.contents; + /// foreach(var packedAssetInfo in contents) + /// { + /// // Path of the asset that contains this object + /// var path = packedAssetInfo.sourceAssetPath; + /// + /// if (string.IsNullOrEmpty(path)) + /// path = "Internal"; + /// + /// if (sourceAssetSize.ContainsKey(path)) + /// { + /// var existingEntry = sourceAssetSize[path]; + /// existingEntry.size += packedAssetInfo.packedSize; + /// existingEntry.objectCount++; + /// sourceAssetSize[path] = existingEntry; + /// } + /// else + /// { + /// sourceAssetSize[path] = new ContentEntry + /// { + /// size = packedAssetInfo.packedSize, + /// objectCount = 1 + /// }; + /// } + /// } + /// } + /// + /// sb.AppendLine("The Build contains the content from the following source assets:\n"); + /// + /// // Sort biggest to smallest + /// var sortedSourceAssetSize = sourceAssetSize.OrderByDescending(x => x.Value.size); + /// + /// // Note: for large builds there could be thousands or more different source assets, + /// // in which case it could be prudent to only show the top 10 or top 100 results. + /// for (int i = 0; i < sortedSourceAssetSize.Count(); i++) + /// { + /// var entry = sortedSourceAssetSize.ElementAt(i); + /// sb.AppendLine(" Asset: \"" + entry.Key + "\" Object Count: " + entry.Value.objectCount + " Size of Objects: " + entry.Value.size); + /// } + /// + /// return sb.ToString(); + /// } + ///} + ///]]> + /// + /// + /// [NativeType(Header = "Modules/BuildReportingEditor/Public/PackedAssets.h")] public struct PackedAssetInfo { + ///Local file id of the object + /// + ///For Serialized Files this is the local file id of the object in the file in the build output. It will be unique within that file. + ///During the builds ids are reassigned, so this id will be different from the id of the object in its source scene or asset. + /// + ///This ID is 0 for the content of .resS and .resource files. + /// [NativeName("fileID")] public long id { get; } + ///The type of the object whose serialized data is represented by the Packed Asset, such as , or . public Type type { get; } + ///The size in bytes of the Packed Asset. + ///This is the size prior to any compression. The actual size on disk can be smaller when the file is stored inside a Unity Archive (e.g. in the case of a AssetBundle, or a Player built with ). + /// + ///Note: there can be extra padding bytes inserted between Packed Assets, added for alignment purpose. + ///Because of this, the offset + packedSize may be slightly smaller than the offset of the next element in the PackedAsset array. + /// public ulong packedSize { get; } + ///The offset from the start of the file to the first byte of the range belonging to the Packed Asset. public ulong offset { get; } + ///The Global Unique Identifier (GUID) of the source Asset that the build process used to generate the packed Asset. + /// public GUID sourceAssetGUID { get; } + ///The file path to the source Asset that the build process used to generate the Packed Asset, relative to the Project directory. + ///Note: the same path may be repeated many times in the PackedAssets array, because PackedAssets track objects, and a single Asset can contain many objects. + /// + ///Note: Some packed Assets might not have a source Asset. For example a Sprite Atlas that is generated at build time. Also, AssetBundles contain generated objects that do not come from any source asset, e.g. the . [NativeName("buildTimeAssetPath")] public string sourceAssetPath { get; } } diff --git a/Modules/BuildReportingEditor/Managed/PackedAssets.bindings.cs b/Modules/BuildReportingEditor/Managed/PackedAssets.bindings.cs index 324a22f353..45a941888b 100644 --- a/Modules/BuildReportingEditor/Managed/PackedAssets.bindings.cs +++ b/Modules/BuildReportingEditor/Managed/PackedAssets.bindings.cs @@ -9,6 +9,68 @@ namespace UnityEditor.Build.Reporting { + ///An extension to the class that tracks how Assets contribute to the size of the build. + ///The build process generates a PackedAssets object for each Serialized File, resS and resource file generated by a build. Serialized Files contain serialized Unity Objects from scenes and assets. + /// + ///The PackedAsset information can be used to analyze how specific assets or types contribute to the size of the build, for example to calculate the total size of all textures. + /// + ///Example file names for Serialized Files in the output of a Player build are resources.assets, sharedassets0.assets and globalgamemanagers.assets. + ///Note: The content of scenes in the output of a Player build are written to Serialized Files with the names level0, level1, level2 etc. + ///However there are no PackedAsset objects generated for level files, nor for the globalgamemanager file. + /// + ///AssetBundles containing assets will have a single Serialized File, with a name like "CAB-b8befc517982290c55526f35cbb7f03d". AssetBundles containing scenes will contain multiple Serialized Files. + /// + ///The PackedAssets for a Serialized File records the size of the header in the overhead property, and then information about each object in the contents property. + /// + ///Files with the .resource contain audio or video data which is referenced by an or object inside the associated Serialized File. + ///For example level1.resource contains audio and video data from objects inside the Serialized File level1. + ///The PackedAsset for a .resource file records information about the originating asset for each blob of audio or video data in the .resource file. + /// + ///Similarly, the PackedAsset object for a .resS file records information about the size and origin of and data inside the file. + /// + ///Note: For large builds the PackedAsset objects can grow very large, and consume a significant amount of memory. When using this data it is recommended to do a single pass through the data to populate smaller data structures or to export it to another format, as required by external tools. + /// + /// + /// + /// [NativeType(Header = "Modules/BuildReportingEditor/Public/PackedAssets.h")] [NativeClass("BuildReporting::PackedAssets")] public sealed class PackedAssets : Object @@ -17,16 +79,28 @@ public sealed class PackedAssets : Object [Obsolete(fileObsoleteMessage, true)] public uint file => throw new NotSupportedException(fileObsoleteMessage); + ///The file name + ///For player builds this the filename relative to the Data folder of the build, for example "globalgamemanagers.assets.resS". + /// + ///For an AssetBundle this is the filename inside the Unity Archive file, for example "CAB-cc6c60ef8808e0fc6663136604321554" and "CAB-cc6c60ef8808e0fc6663136604321554.resS". + /// public string shortPath { get { return GetShortPath(); } } + ///The size of the header section of the referenced file. + ///Some file formats have no header, in which case this returns zero. public ulong overhead { get { return GetOverhead(); } } + ///An array of objects that holds information about the content portion of the referenced file. + ///A Serialized File is made up of a header section, and then a flat list of the objects, in their binary serialized form. + ///Each entry in the PackedAssetInfo array corresponds to one of these serialized objects, in the order they are saved in the file. + /// + ///Similarly a .resS or .resource file is made of a sequence of binary blobs of audio, video, texture, mesh or other large data types. The PackedAssetInfo array has an entry for each of these blobs. public PackedAssetInfo[] contents { get { return GetContents(); } diff --git a/Modules/BuildReportingEditor/Managed/ScenesUsingAsset.cs b/Modules/BuildReportingEditor/Managed/ScenesUsingAsset.cs index 4c717a8b4e..a30647a800 100644 --- a/Modules/BuildReportingEditor/Managed/ScenesUsingAsset.cs +++ b/Modules/BuildReportingEditor/Managed/ScenesUsingAsset.cs @@ -7,10 +7,13 @@ namespace UnityEditor.Build.Reporting { + ///Contains information about which scenes in a build have references to an Asset in the build. [NativeType(Header = "Modules/BuildReportingEditor/Public/ScenesUsingAssets.h")] public struct ScenesUsingAsset { + ///The asset path. public string assetPath { get; } + ///The list of scenes in the build referring to the asset, identified by a string containing the scene index in the list, as well as the scene path. public string[] scenePaths { get; } } } diff --git a/Modules/BuildReportingEditor/Managed/ScenesUsingAssets.bindings.cs b/Modules/BuildReportingEditor/Managed/ScenesUsingAssets.bindings.cs index 0b7d0f95d1..0908b36e7a 100644 --- a/Modules/BuildReportingEditor/Managed/ScenesUsingAssets.bindings.cs +++ b/Modules/BuildReportingEditor/Managed/ScenesUsingAssets.bindings.cs @@ -8,10 +8,13 @@ namespace UnityEditor.Build.Reporting { + ///An extension to the class that tracks which scenes in the build have references to a specific asset in the build. + ///The build process generates this information when is used during a build. [NativeType(Header = "Modules/BuildReportingEditor/Public/ScenesUsingAssets.h")] [NativeClass("BuildReporting::ScenesUsingAssets")] public sealed class ScenesUsingAssets : Object { + ///An array of that holds information about the Assets that are included in the build. public ScenesUsingAsset[] list { get { return GetList(); } diff --git a/Modules/BuildReportingEditor/Managed/StrippingInfo.cs b/Modules/BuildReportingEditor/Managed/StrippingInfo.cs index 0f3d88efa7..766ceea27c 100644 --- a/Modules/BuildReportingEditor/Managed/StrippingInfo.cs +++ b/Modules/BuildReportingEditor/Managed/StrippingInfo.cs @@ -12,10 +12,19 @@ namespace UnityEditor.Build.Reporting { + ///The StrippingInfo object contains information about which native code modules in the engine are still present in the build, and the reasons why they are still present. public class StrippingInfo : ScriptableObject, ISerializationCallbackReceiver { + ///The native engine modules that were included in the build. + ///You can pass each of these to to obtain information about what caused a module to be included in the build. public IEnumerable includedModules { get { return modules; } } + ///Returns the list of dependencies or reasons that caused the given entity to be included in the build. + ///The returned list of strings may include names of components, internal engine objects, other modules, or other human-readable reasons. To obtain further information, you can pass each string back into GetReasonsForIncluding again. + /// + ///For example, calling GetReasonsForIncluding("Physics Module") may return a list that includes "Rigidbody", and you can then call GetReasonsForIncluding("Rigidbody") to get more information about which Scenes or assets are using the Rigidbody component. + ///The name of an engine module, class, or other entity present in the build. + ///A list of modules, classes, or other entities that caused the provided entity to be included in the build. public IEnumerable GetReasonsForIncluding(string entityName) { HashSet deps; diff --git a/Modules/EditorToolbar/ToolbarElements/SnapSettings.cs b/Modules/EditorToolbar/ToolbarElements/SnapSettings.cs index 5963e937f5..35775ab451 100644 --- a/Modules/EditorToolbar/ToolbarElements/SnapSettings.cs +++ b/Modules/EditorToolbar/ToolbarElements/SnapSettings.cs @@ -17,6 +17,7 @@ public SnapSize() name = "SceneViewSnapSize"; value = GridSettings.size.x; showMixedValue = !GridSettings.linked; + isDelayed = true; GridSettings.sizeChanged += newValue => { diff --git a/Modules/Physics2D/ScriptBindings/Physics2D.bindings.cs b/Modules/Physics2D/ScriptBindings/Physics2D.bindings.cs index e409a0af31..3325b4102f 100644 --- a/Modules/Physics2D/ScriptBindings/Physics2D.bindings.cs +++ b/Modules/Physics2D/ScriptBindings/Physics2D.bindings.cs @@ -3430,8 +3430,8 @@ public SlideResults Slide(Vector2 velocity, float deltaTime, SlideMovement slide if (!float.IsFinite(slideMovement.gravitySlipAngle) || slideMovement.gravitySlipAngle < 0f || slideMovement.gravitySlipAngle > 90f) throw new ArgumentException($"Gravity Slip Angle must be in the range of 0 to 90 degrees. It is {slideMovement.gravitySlipAngle}.", "SlideMovement.gravitySlipAngle"); - if (!float.IsFinite(slideMovement.surfaceUp.x) || !float.IsFinite(slideMovement.surfaceUp.y) || slideMovement.surfaceUp.sqrMagnitude < Mathf.Epsilon) - throw new ArgumentException($"Surface Up is invalid and must be non-zero magnitude. It is {slideMovement.surfaceUp}.", "SlideMovement.surfaceUp"); + if (!float.IsFinite(slideMovement.surfaceUp.x) || !float.IsFinite(slideMovement.surfaceUp.y)) + throw new ArgumentException($"Surface Up is invalid. It is {slideMovement.surfaceUp}.", "SlideMovement.surfaceUp"); if (!float.IsFinite(slideMovement.surfaceAnchor.x) || !float.IsFinite(slideMovement.surfaceAnchor.y)) throw new ArgumentException($"Surface Anchor is invalid. It is {slideMovement.surfaceAnchor}.", "SlideMovement.surfaceAnchor"); diff --git a/Modules/ShortcutManagerEditor/ShortcutHelperBarUtility.cs b/Modules/ShortcutManagerEditor/ShortcutHelperBarUtility.cs index 9b1d7441f4..059bea331f 100644 --- a/Modules/ShortcutManagerEditor/ShortcutHelperBarUtility.cs +++ b/Modules/ShortcutManagerEditor/ShortcutHelperBarUtility.cs @@ -175,10 +175,20 @@ public static void OnClientDisable(IShortcutUpdate client) public static void RemoveAppStatusBarClient() { - s_Clients.RemoveWhere(c => c is ShortcutHelperBar); + s_Clients.RemoveWhere(IsShortcutHelperBar); ClearIfNoClients(); } + static bool IsShortcutHelperBar(IShortcutUpdate client) + { + if (client is ShortcutHelperBar bar) + { + bar.OnDisable(); + return true; + } + return false; + } + static void UpdateClients() { foreach (var client in s_Clients) diff --git a/Modules/TextCoreTextEngineEditor/Managed/FontAssetCreatorWindow.cs b/Modules/TextCoreTextEngineEditor/Managed/FontAssetCreatorWindow.cs index 51a567fc95..7822daff4b 100644 --- a/Modules/TextCoreTextEngineEditor/Managed/FontAssetCreatorWindow.cs +++ b/Modules/TextCoreTextEngineEditor/Managed/FontAssetCreatorWindow.cs @@ -478,13 +478,13 @@ void DrawControls() GUILayout.BeginHorizontal(); EditorGUI.BeginChangeCheck(); - m_PaddingFieldValue = EditorGUILayout.FloatField("Padding", m_PaddingFieldValue); + m_PaddingFieldValue = Mathf.Max(EditorGUILayout.FloatField("Padding", m_PaddingFieldValue), 0); int selection = m_PaddingMode == PaddingMode.Undefined || m_PaddingMode == PaddingMode.Pixel ? 1 : 0; selection = GUILayout.SelectionGrid(selection, k_PaddingOptionLabels, 2); if (m_PaddingMode == PaddingMode.Percentage) - m_PaddingFieldValue = (int)(m_PaddingFieldValue + 0.5f); + m_PaddingFieldValue = Mathf.Min((int)(m_PaddingFieldValue + 0.5f), float.MaxValue); if (EditorGUI.EndChangeCheck()) { diff --git a/Modules/UIBuilder/Editor/Builder/Library/BuilderLibrary.cs b/Modules/UIBuilder/Editor/Builder/Library/BuilderLibrary.cs index bde94f7f98..157b89a7f9 100644 --- a/Modules/UIBuilder/Editor/Builder/Library/BuilderLibrary.cs +++ b/Modules/UIBuilder/Editor/Builder/Library/BuilderLibrary.cs @@ -253,7 +253,6 @@ BuilderLibraryTreeView controlsTreeView : BuilderLibraryContent.standardControlsTreeNoEditor; m_ControlsTreeView = new BuilderLibraryTreeView(controlsTree); - m_ControlsTreeView.viewDataKey = "unity-ui-builder-library-controls-tree"; SetUpLibraryView(m_ControlsTreeView); return m_ControlsTreeView; diff --git a/Modules/UIBuilder/Editor/Builder/Library/BuilderLibraryTreeView.cs b/Modules/UIBuilder/Editor/Builder/Library/BuilderLibraryTreeView.cs index 0794f4511d..698fcaf5c9 100644 --- a/Modules/UIBuilder/Editor/Builder/Library/BuilderLibraryTreeView.cs +++ b/Modules/UIBuilder/Editor/Builder/Library/BuilderLibraryTreeView.cs @@ -46,15 +46,13 @@ public BuilderLibraryTreeView(IList items) Add(m_TreeView); m_Items = items; - m_TreeView.viewDataKey = "samples-tree"; + m_TreeView.viewDataKey = "unity-ui-builder-library-controls-tree"; m_TreeView.fixedItemHeight = 20; m_TreeView.SetRootItems(items); m_TreeView.makeItem = MakeItem; m_TreeView.bindItem = BindItem; m_TreeView.itemsChosen += OnItemsChosen; m_TreeView.Rebuild(); - - m_TreeView.ExpandRootItems(); } void OnContextualMenuPopulateEvent(ContextualMenuPopulateEvent evt) @@ -202,10 +200,10 @@ public override void FilterView(string value) if (string.IsNullOrEmpty(value) && m_IsSearching) { - m_TreeView.viewController.CollapseAll(); + m_TreeView.CollapseAll(); foreach (var id in m_PreviouslyExpandedIds) { - m_TreeView.viewController.ExpandItem(id, false); + m_TreeView.ExpandItem(id); } m_PreviouslyExpandedIds.Clear(); m_IsSearching = false; diff --git a/Modules/UIBuilder/Editor/Builder/Viewport/BuilderInPlaceTextEditingUtilities.cs b/Modules/UIBuilder/Editor/Builder/Viewport/BuilderInPlaceTextEditingUtilities.cs index 8ab6d1d127..040e54624e 100644 --- a/Modules/UIBuilder/Editor/Builder/Viewport/BuilderInPlaceTextEditingUtilities.cs +++ b/Modules/UIBuilder/Editor/Builder/Viewport/BuilderInPlaceTextEditingUtilities.cs @@ -17,6 +17,7 @@ struct EditingContext { public VisualElement editedElement; public TextElement targetTextElement; + public VisualElement editorLayer; public string uxmlAttributeName; public string propertyName; @@ -136,10 +137,10 @@ static EditingContext GetAttributeToEdit(VisualElement editedElement, string uxm public static void OpenEditor(VisualElement element, Vector2 pos, VisualElement documentRoot) { var viewport = element.GetFirstAncestorOfType(); - var editorLayer = viewport.editorLayer; var textEditor = viewport.textEditor; var context = GetAttributeToEdit(element, k_TextAttributeName); + context.editorLayer = viewport.editorLayer; if (context.targetTextElement == null || string.IsNullOrEmpty(context.uxmlAttributeName)) return; @@ -167,7 +168,7 @@ public static void OpenEditor(VisualElement element, Vector2 pos, VisualElement context.editedElement.SetValueByReflection(context.propertyName, k_DummyText); } - editorLayer.RemoveFromClassList(BuilderConstants.HiddenStyleClassName); + context.editorLayer.RemoveFromClassList(BuilderConstants.HiddenStyleClassName); var textInput = textEditor.Q(TextField.textInputUssName); textEditor.SetValueWithoutNotify(value); @@ -207,6 +208,7 @@ public static void OpenEditor(VisualElement element, Vector2 pos, VisualElement textInput.RegisterCallback(OnFocusOutEvent, context, TrickleDown.TrickleDown); textEditor.RegisterCallback, EditingContext>(OnTextChanged, context); + element.RegisterCallback(OnDetachFromPanelEvent, context, TrickleDown.TrickleDown); } static void OnTextElementGeometryChanged(GeometryChangedEvent evt, EditingContext context) @@ -242,13 +244,15 @@ static void UpdateTextEditorGeometry(EditingContext context) private static void CloseEditor(EditingContext context) { + context.editorLayer.AddToClassList(BuilderConstants.HiddenStyleClassName); + context.editedElement.UnregisterCallback(OnDetachFromPanelEvent, TrickleDown.TrickleDown); + var viewport = context.editedElement.GetFirstAncestorOfType(); if (null == viewport) return; viewport.textEditor.UnregisterCallback(OnFocusOutEvent, TrickleDown.TrickleDown); viewport.textEditor.UnregisterCallback, EditingContext>(OnTextChanged); - viewport.editorLayer.AddToClassList(BuilderConstants.HiddenStyleClassName); context.targetTextElement.UnregisterCallback(OnTextElementGeometryChanged); } @@ -262,6 +266,12 @@ static void OnFocusOutEvent(FocusOutEvent evt, EditingContext context) OnEditTextFinished(context); } + static void OnDetachFromPanelEvent(DetachFromPanelEvent evt, EditingContext context) + { + // Any change to the hierarchy or actions like undoing will cause a refresh of the element. Close the editor to avoid staying in a dead state. (UUM-87944) + CloseEditor(context); + } + static void OnEditTextFinished(EditingContext context) { if (!context.CanEdit) diff --git a/Modules/UIElements/Core/Collections/Controllers/BaseTreeViewController.cs b/Modules/UIElements/Core/Collections/Controllers/BaseTreeViewController.cs index c85e7dcb54..d7d0ba8cf7 100644 --- a/Modules/UIElements/Core/Collections/Controllers/BaseTreeViewController.cs +++ b/Modules/UIElements/Core/Collections/Controllers/BaseTreeViewController.cs @@ -569,9 +569,6 @@ public virtual bool CanChangeExpandedState(int id) /// Whether the item with the specified ID is expanded in the tree. public bool IsExpanded(int id) { - if (IsViewDataKeyEnabled()) - return baseTreeView.expandedItemIds.Contains(id); - return m_IdToNodeDictionary.ContainsKey(id) && m_Hierarchy.Exists(m_IdToNodeDictionary[id]) && m_HierarchyViewModel.HasAllFlags(m_IdToNodeDictionary[id], HierarchyNodeFlags.Expanded); } @@ -696,15 +693,15 @@ void ExpandItemByNode(in HierarchyNode node, bool expandAllChildren, bool refres if (!CanChangeExpandedState(id)) return; - // Using a HashSet in order to prevent duplicates and it is faster than List.Contains(id) m_HierarchyViewModel.SetFlags(node, HierarchyNodeFlags.Expanded, expandAllChildren); m_HierarchyHasPendingChanged = true; + // Required to update the expandedItemIds, can get rid of once we find a way to handle the serialized + // field for the viewDataKey if (IsViewDataKeyEnabled()) { + // Using a HashSet in order to prevent duplicates and it is faster than List.Contains(id) var hashSet = new HashSet(baseTreeView.expandedItemIds) { id }; - // Required to update the expandedItemIds, can get rid of once we find a way to handle the serialized - // field for the viewDataKey if (expandAllChildren) { // We need to refresh the view model in order the updated nodes @@ -749,7 +746,7 @@ void CollapseItemByNode(in HierarchyNode node, bool collapseAllChildren, bool re baseTreeView.SaveViewData(); } - m_HierarchyViewModel.ClearFlags(GetHierarchyNodeById(id), HierarchyNodeFlags.Expanded, collapseAllChildren); + m_HierarchyViewModel.ClearFlags(node, HierarchyNodeFlags.Expanded, collapseAllChildren); m_HierarchyHasPendingChanged = true; if (refresh) diff --git a/Modules/UIElements/Core/Events/EventDispatchUtilities.cs b/Modules/UIElements/Core/Events/EventDispatchUtilities.cs index 483961b086..5b54129794 100644 --- a/Modules/UIElements/Core/Events/EventDispatchUtilities.cs +++ b/Modules/UIElements/Core/Events/EventDispatchUtilities.cs @@ -219,14 +219,9 @@ private static void HandleEventAcrossPropagationPathWithCompatibilityEvent(Event compatibilityEvt.skipDisabledElements = evt.skipDisabledElements; if (DebuggerEventDispatchUtilities.InterceptEvent(compatibilityEvt, panel)) - { - HandleEventAcrossPropagationPath(evt, panel, target, isCapturingTarget); - DebuggerEventDispatchUtilities.PostDispatch(compatibilityEvt, panel); return; - } using var path = PropagationPaths.Build(target, evt, eventCategories); - try { Debug.Assert(!evt.dispatch, "Event is being dispatched recursively."); @@ -344,8 +339,6 @@ private static void HandleEventAcrossPropagationPathWithCompatibilityEvent(Event compatibilityEvt.propagationPhase = PropagationPhase.None; evt.dispatch = false; - - DebuggerEventDispatchUtilities.PostDispatch(compatibilityEvt, panel); } } diff --git a/Modules/UIElements/Core/Events/MouseEvents.cs b/Modules/UIElements/Core/Events/MouseEvents.cs index 062f58738c..04a85d86bd 100644 --- a/Modules/UIElements/Core/Events/MouseEvents.cs +++ b/Modules/UIElements/Core/Events/MouseEvents.cs @@ -292,6 +292,8 @@ protected internal override void PreDispatch(IPanel panel) protected internal override void PostDispatch(IPanel panel) { + DebuggerEventDispatchUtilities.PostDispatch(this, (BaseVisualElementPanel)panel); + if (sourcePointerEvent is EventBase pointerEvent) { // pointerEvent processing should not be done and it should not have returned to the pool. @@ -976,6 +978,9 @@ protected override void Init() void LocalInit() { propagation = EventPropagation.Bubbles; + + // Don't recompute top element before dispatch, we want a last valid target for this event. + // Note that PostDispatch clears the top element right after, so it will still end up null. recomputeTopElementUnderMouse = false; } @@ -1007,9 +1012,11 @@ protected internal override void PostDispatch(IPanel panel) // of a drag and drop operation, at the very beginning of the drag. Since // we are not really exiting the window, we do not want to set the element // under mouse to null in this case. - if (pressedButtons == 0) + if (pressedButtons == 0 && panel is BaseVisualElementPanel elementPanel) { - (panel as BaseVisualElementPanel)?.ClearCachedElementUnderPointer(PointerId.mousePointerId, this); + elementPanel.ClearCachedElementUnderPointer(PointerId.mousePointerId, this); + // Call CommitElementUnderPointers manually because recomputeTopElementUnderMouse is false. + elementPanel.CommitElementUnderPointers(); } base.PostDispatch(panel); diff --git a/README.md b/README.md index 60db38ef99..87b7916327 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## Unity 6000.1.0b3 C# reference source code +## Unity 6000.1.0b4 C# reference source code The C# part of the Unity engine and editor source code. May be used for reference purposes only. diff --git a/Runtime/Export/Math/Color.cs b/Runtime/Export/Math/Color.cs index c4e3134637..d5d9ed5eb3 100644 --- a/Runtime/Export/Math/Color.cs +++ b/Runtime/Export/Math/Color.cs @@ -844,8 +844,8 @@ public static Color HSVToRGB(float H, float S, float V, bool hdr) // Color Preset of @@RGBA(0.9607844f, 0.9607844f, 0.9607844f, 1f)@@ public static Color whiteSmoke { [MethodImpl(MethodImplOptionsEx.AggressiveInlining)] get => new(0.9607844f, 0.9607844f, 0.9607844f, 1f); } - // Color Preset of @@RGBA(1f, 1f, 0f, 1f)@@ - public static Color yellow { [MethodImpl(MethodImplOptionsEx.AggressiveInlining)] get => new(1f, 1f, 0f, 1f); } + // Color Preset of @@RGBA(1f, 0.92f, 0.016f, 1f)@@ + public static Color yellow { [MethodImpl(MethodImplOptionsEx.AggressiveInlining)] get => new(1f, 235f / 255f, 4f / 255f, 1f); } // Color Preset of @@RGBA(0.6039216f, 0.8039216f, 0.1960784f, 1f)@@ public static Color yellowGreen { [MethodImpl(MethodImplOptionsEx.AggressiveInlining)] get => new(0.6039216f, 0.8039216f, 0.1960784f, 1f); } From b33ec10c1dcf76c1d903006345e41d07133abbd8 Mon Sep 17 00:00:00 2001 From: Unity Technologies Date: Tue, 4 Feb 2025 16:57:33 +0000 Subject: [PATCH 02/19] Unity 6000.1.0b5 C# reference source code --- Editor/Mono/Inspector/CameraEditorUtils.cs | 6 ++ .../Inspector/RenderPipelineEditorUtility.cs | 17 +++++ Editor/Mono/SceneView/SceneView.cs | 18 ++++- Editor/Mono/Tools/EditorToolCache.cs | 18 +---- .../Mono/UIElements/Controls/PropertyField.cs | 16 ++++ Modules/IMGUI/TextEditor.cs | 6 +- .../Services/Common/BasePackageVersion.cs | 3 + .../Services/Packages/Actions/RemoveAction.cs | 2 +- .../Services/Pages/PageTypes/BuiltInPage.cs | 4 +- .../Editor/UI/PackageDetailsHeader.cs | 50 +------------ .../Editor/UI/VersionInfoIcon.cs | 73 +++++++++++++++++++ .../Editor/Indexing/IndexManager.cs | 41 +++++++++-- .../Editor/Indexing/SearchDatabase.cs | 27 ++++--- .../Editor/Indexing/SearchDatabaseImporter.cs | 2 + .../Indexing/SearchIndexEntryImporter.cs | 8 +- .../Editor/Indexing/SearchIndexer.cs | 10 +++ .../Editor/Indexing/SearchNativeList.cs | 1 + .../QuickSearch/Editor/Indexing/SearchTask.cs | 2 + Modules/QuickSearch/Editor/UI/Dispatcher.cs | 2 + Modules/QuickSearch/Editor/UITK/SearchView.cs | 8 ++ .../QuickSearch/Editor/UITK/SearchWindow.cs | 15 ++-- .../Editor/Utilities/HashingUtils.cs | 39 ++++++++++ .../Utilities/SearchDisposableTracker.cs | 57 +++++++++++++++ .../SceneTemplateProjectSettings.cs | 4 +- Modules/SceneView/CameraOverlay.cs | 8 ++ .../Managed/TextGenerator.cs | 2 +- .../TextGeneratorHtmlTagValidation.cs | 8 +- .../TextGeneratorPreferredValues.cs | 4 + Modules/UIBuilder/Editor/Builder/Builder.cs | 11 ++- .../Document/BuilderDocumentOpenUXML.cs | 2 +- .../Inspector/BuilderInspectorStyleFields.cs | 7 +- .../StyleField/DimensionStyleField.cs | 65 +++++++++++++++++ .../StyleField/FieldSearchCompleter.cs | 4 +- .../StyleField/StyleVariableUtilities.cs | 2 +- .../Utilities/StyleField/VariableCompleter.cs | 28 ++++--- .../StyleField/VariableEditingHandler.cs | 2 + .../StyleSheetUtilities.cs | 2 +- .../Bindings/VisualTreeDataBindingUpdater.cs | 4 +- Modules/UIElements/Core/Controls/Tab.cs | 2 +- Modules/UIElements/Core/Controls/TabView.cs | 64 ++++++++++++++-- .../ToggleButtonGroup/ToggleButtonGroup.cs | 2 +- .../Core/Controls/TwoPaneSplitView.cs | 8 +- Modules/UIElements/Core/Panel.cs | 10 ++- .../Core/Style/Generated/InitialStyle.cs | 2 +- .../Core/StylePropertyAnimationSystem.cs | 4 +- Modules/UIElements/Core/Text/ATGTextHandle.cs | 4 +- .../UIElements/Core/Text/UITKTextHandle.cs | 4 +- .../UIElements/Core/VisualElementHierarchy.cs | 6 +- Modules/UIElementsEditor/PanelDebug.cs | 5 +- Projects/CSharp/UnityEditor.csproj | 9 +++ README.md | 2 +- .../Export/RenderPipeline/RenderPipeline.cs | 12 +++ .../RenderPipeline/RenderPipelineManager.cs | 2 +- 53 files changed, 556 insertions(+), 158 deletions(-) create mode 100644 Modules/PackageManagerUI/Editor/UI/VersionInfoIcon.cs create mode 100644 Modules/QuickSearch/Editor/Utilities/HashingUtils.cs create mode 100644 Modules/QuickSearch/Editor/Utilities/SearchDisposableTracker.cs diff --git a/Editor/Mono/Inspector/CameraEditorUtils.cs b/Editor/Mono/Inspector/CameraEditorUtils.cs index f0bb68f270..d35e7e5d65 100644 --- a/Editor/Mono/Inspector/CameraEditorUtils.cs +++ b/Editor/Mono/Inspector/CameraEditorUtils.cs @@ -496,6 +496,10 @@ static RenderTexture RenderInternal(Camera cameraToRender, PreviewSettings setti RenderTexture.active = oldRt; } + // Honor async shader compilation editor settings for this preview + bool oldShaderAsyncState = ShaderUtil.allowAsyncCompilation; + ShaderUtil.allowAsyncCompilation = EditorSettings.asyncShaderCompilation; + using (new SavedStateForCameraPreview(cameraToRender)) { // make sure the preview camera is rendering the same stage as the SceneView is @@ -520,6 +524,8 @@ static RenderTexture RenderInternal(Camera cameraToRender, PreviewSettings setti previewCamera.Render(); } } + + ShaderUtil.allowAsyncCompilation = oldShaderAsyncState; return rt; } } diff --git a/Editor/Mono/Inspector/RenderPipelineEditorUtility.cs b/Editor/Mono/Inspector/RenderPipelineEditorUtility.cs index 1b537c2ea9..498172f667 100644 --- a/Editor/Mono/Inspector/RenderPipelineEditorUtility.cs +++ b/Editor/Mono/Inspector/RenderPipelineEditorUtility.cs @@ -265,5 +265,22 @@ internal static bool DoesMaskContainRenderingLayersOutsideOfMaxBitCount(uint mas /// A string with the warning message about layers beyond the supported bit count being ignored. internal static string GetOutsideOfMaxBitCountWarningMessage(int bitCount) => $"Current mask contains layers outside of a supported range by active Render Pipeline. The active Render Pipeline only supports up to {bitCount} layers. Rendering Layers above {bitCount} are ignored."; + + internal static bool SupportPreview(Camera camera, out string reason) + { + if (!RenderPipelineManager.isCurrentPipelineValid) + { + //Thus we are in Built-in Render Pipeline. Preview are supported here. + if (camera == null || camera.Equals(null)) + { + reason = "Camera is null"; + return false; + } + reason = null; + return true; + } + + return RenderPipelineManager.currentPipeline.IsPreviewSupported(camera, out reason); + } } } diff --git a/Editor/Mono/SceneView/SceneView.cs b/Editor/Mono/SceneView/SceneView.cs index c6e84b264b..e93e0fc304 100644 --- a/Editor/Mono/SceneView/SceneView.cs +++ b/Editor/Mono/SceneView/SceneView.cs @@ -1212,7 +1212,7 @@ internal enum DraggingLockedState private Object m_LastLockedObject; [SerializeField] - private DrawCameraMode m_LastDebugDrawMode = DrawCameraMode.GIContributorsReceivers; + private CameraMode m_LastDebugDrawMode = new CameraMode() { drawMode = DrawCameraMode.GIContributorsReceivers }; [SerializeField] bool m_ViewIsLockedToObject; @@ -1414,7 +1414,7 @@ public override void OnEnable() // If this a draw mode for debugging purposes, take note of it, so we can toggle back and forth between it and the previous mode. if (cameraMode.drawMode != DrawCameraMode.Textured && cameraMode.drawMode != DrawCameraMode.Wireframe && cameraMode.drawMode != DrawCameraMode.TexturedWire) { - m_LastDebugDrawMode = cameraMode.drawMode; + m_LastDebugDrawMode = cameraMode; } }; @@ -2062,6 +2062,12 @@ void HandleClickAndDragToFocus() else if (GUIUtility.hotControl == 0 && draggingLocked == DraggingLockedState.Dragging) draggingLocked = DraggingLockedState.LookAt; + // UUM-90436. UITK's MouseEnterEvent/MouseEnterWindowEvent callbacks that + // drive `viewportsUnderMouse` seem to not fire reliably when a pen tablet is used. + if (!sceneViewMotion.viewportsUnderMouse && + (evt.type == EventType.MouseDown || evt.type == EventType.MouseMove)) + sceneViewMotion.viewportsUnderMouse = true; + if (evt.type == EventType.MouseDown) { Tools.s_ButtonDown = evt.button; @@ -2822,11 +2828,17 @@ internal void SwitchToRenderMode(DrawCameraMode mode, bool sceneLighting = true) this.cameraMode = GetBuiltinCameraMode(mode); } + internal void SwitchToRenderMode(CameraMode mode, bool sceneLighting = true) + { + this.sceneLighting = sceneLighting; + this.cameraMode = mode; + } + internal void SwitchToUnlit() => SwitchToRenderMode(DrawCameraMode.Textured, false); internal void ToggleLastDebugDrawMode() { - if (cameraMode.drawMode == m_LastDebugDrawMode) + if (cameraMode.drawMode == m_LastDebugDrawMode.drawMode) { SwitchToRenderMode(DrawCameraMode.Textured); } diff --git a/Editor/Mono/Tools/EditorToolCache.cs b/Editor/Mono/Tools/EditorToolCache.cs index 7f12b503d5..ea00aae5bb 100644 --- a/Editor/Mono/Tools/EditorToolCache.cs +++ b/Editor/Mono/Tools/EditorToolCache.cs @@ -287,28 +287,14 @@ public void InstantiateEditors(EditorToolContext ctx, List edit { editors.Clear(); - // If the shared tracker is locked, use fallback tracker instance so that the current selection is always + // If the shared tracker is locked, use fallback tracker instance so that the active selection is always // represented. Addresses case where a single locked inspector is open. var shared = ActiveEditorTracker.sharedTracker; var activeTracker = shared.isLocked ? ActiveEditorTracker.fallbackTracker : shared; - var propertyEditors = PropertyEditor.GetPropertyEditors(); - // Collect editor tools for the shared tracker first, then any locked inspectors or open properties editors + // We collect editors only for the tracker that represents the active selection. CollectEditorsForTracker(ctx, activeTracker, editors); - foreach (var propertyEditor in propertyEditors) - { - if (propertyEditor is InspectorWindow) - { - if ((propertyEditor as InspectorWindow).isLocked) - CollectEditorsForTracker(ctx, propertyEditor.tracker, editors); - } - else - { - CollectEditorsForTracker(ctx, propertyEditor.tracker, editors); - } - } - foreach (var editor in editors) editor.InstantiateEditor(); } diff --git a/Editor/Mono/UIElements/Controls/PropertyField.cs b/Editor/Mono/UIElements/Controls/PropertyField.cs index b38fef551f..be0498f2de 100644 --- a/Editor/Mono/UIElements/Controls/PropertyField.cs +++ b/Editor/Mono/UIElements/Controls/PropertyField.cs @@ -760,10 +760,26 @@ private TField ConfigureField(TField field, SerializedProperty p field.label = fieldLabel; ConfigureFieldStyles(field); + ConfigureTooltip(property, field); return field; } + private void ConfigureTooltip(SerializedProperty property, BaseField field) + { + var fieldInfo = ScriptAttributeUtility.GetFieldInfoFromProperty(property, out _); + + if (fieldInfo == null) + { + return; + } + + var hasTooltipAttribute = fieldInfo.IsDefined(typeof(TooltipAttribute), false); + + // Don't display elided tooltip if the property has a TooltipAttribute. + field.labelElement.displayTooltipWhenElided = !hasTooltipAttribute; + } + private VisualElement ConfigureLabelOnly(SerializedProperty property) { var wrapper = new VisualElement(); diff --git a/Modules/IMGUI/TextEditor.cs b/Modules/IMGUI/TextEditor.cs index 7bbe1823a8..3d29d15d22 100644 --- a/Modules/IMGUI/TextEditor.cs +++ b/Modules/IMGUI/TextEditor.cs @@ -209,7 +209,11 @@ public bool HasClickedOnHREF(Vector2 mousePosition, out string href) if (!href.StartsWith("href")) return false; // Removes href="..." - href = href.Substring(6, href.Length - 7); + if (href.StartsWith("href=\"") || href.StartsWith("href=\'")) + href = href.Substring(6, href.Length - 7); + // Removes href=... + else + href = href.Substring(5, href.Length - 6); if (Uri.IsWellFormedUriString(href, UriKind.Absolute)) { return true; diff --git a/Modules/PackageManagerUI/Editor/Services/Common/BasePackageVersion.cs b/Modules/PackageManagerUI/Editor/Services/Common/BasePackageVersion.cs index ad7f70e3ae..398b1a1c15 100644 --- a/Modules/PackageManagerUI/Editor/Services/Common/BasePackageVersion.cs +++ b/Modules/PackageManagerUI/Editor/Services/Common/BasePackageVersion.cs @@ -110,6 +110,9 @@ public bool IsDifferentVersionThanRequested => !string.IsNullOrEmpty(versionInManifest) && !HasTag(PackageTag.Git | PackageTag.Local | PackageTag.Custom) && versionInManifest != versionString; + // Request but overridden could happen because other packages/features depend on this version of the package, + // or because of bundled packages in the editor or editor manifest versions that require a specific version of a package + // Here is the list of bundled packages: https://github.cds.internal.unity3d.com/unity/neutron/tree/main/Packages public bool IsRequestedButOverriddenVersion => !string.IsNullOrEmpty(versionString) && !isInstalled && versionString == m_Package?.versions.primary.versionInManifest; diff --git a/Modules/PackageManagerUI/Editor/Services/Packages/Actions/RemoveAction.cs b/Modules/PackageManagerUI/Editor/Services/Packages/Actions/RemoveAction.cs index 885da1a711..ba7b55e97a 100644 --- a/Modules/PackageManagerUI/Editor/Services/Packages/Actions/RemoveAction.cs +++ b/Modules/PackageManagerUI/Editor/Services/Packages/Actions/RemoveAction.cs @@ -151,7 +151,7 @@ internal class DisableIfInstalledAsDependency : DisableCondition public DisableIfInstalledAsDependency(IPackageVersion version) { active = version != null && version.package.versions.installed == version - && (!version.isDirectDependency || version.IsDifferentVersionThanRequested) + && !version.isDirectDependency && !version.isInvalidSemVerInManifest; tooltip = string.Format(k_TooltipTemplate, version?.GetDescriptor() ?? string.Empty); } diff --git a/Modules/PackageManagerUI/Editor/Services/Pages/PageTypes/BuiltInPage.cs b/Modules/PackageManagerUI/Editor/Services/Pages/PageTypes/BuiltInPage.cs index e0459eba51..23bc473fed 100644 --- a/Modules/PackageManagerUI/Editor/Services/Pages/PageTypes/BuiltInPage.cs +++ b/Modules/PackageManagerUI/Editor/Services/Pages/PageTypes/BuiltInPage.cs @@ -19,7 +19,9 @@ internal class BuiltInPage : SimplePage public override string displayName => L10n.Tr("Built-in"); public override Icon icon => Icon.BuiltInPage; - public override RefreshOptions refreshOptions => RefreshOptions.UpmListOffline | RefreshOptions.UpmSearchOffline; + // We use UpmSearch instead of UpmSearchOffline, as search offline never returns packages from scoped registry right now. + // Using UpmSearchOffline here will cause scoped registry packages to disappear when user refreshes the built in page. + public override RefreshOptions refreshOptions => RefreshOptions.UpmListOffline | RefreshOptions.UpmSearch; public override IEnumerable supportedStatusFilters => Enumerable.Empty(); public override IEnumerable supportedSortOptions => k_SupportedSortOptions; diff --git a/Modules/PackageManagerUI/Editor/UI/PackageDetailsHeader.cs b/Modules/PackageManagerUI/Editor/UI/PackageDetailsHeader.cs index ae8a4db1e1..5692faf332 100644 --- a/Modules/PackageManagerUI/Editor/UI/PackageDetailsHeader.cs +++ b/Modules/PackageManagerUI/Editor/UI/PackageDetailsHeader.cs @@ -82,6 +82,7 @@ public void Refresh(IPackage package) detailTitle.SetValueWithoutNotify(m_Version.displayName); detailsLinks.Refresh(m_Version); + versionInfoIcon.Refresh(m_Package); RefreshName(); RefreshDependency(); @@ -89,7 +90,6 @@ public void Refresh(IPackage package) RefreshTags(); RefreshHelpBoxes(); RefreshVersionLabel(); - RefreshVersionInfoIcon(); RefreshRegistryAndAuthor(); RefreshEntitlement(); } @@ -256,52 +256,6 @@ private void RefreshVersionLabel() : string.Format(L10n.Tr("{0} · {1}"), versionString, releaseDateString)); } - private void RefreshVersionInfoIcon() - { - var installed = m_Package?.versions?.installed; - if (installed == null || m_Version == null) - { - UIUtils.SetElementDisplay(versionInfoIcon, false); - return; - } - var installedVersionString = installed.versionString; - if (installed.IsDifferentVersionThanRequested && !installed.isInvalidSemVerInManifest) - { - UIUtils.SetElementDisplay(versionInfoIcon, true); - versionInfoIcon.tooltip = string.Format(L10n.Tr("Unity installed version {0} because another package depends on it (version {0} overrides version {1})."), - installedVersionString, m_Version.versionInManifest); - return; - } - - // If a Unity package doesn't have a recommended version (decided by versions set in the editor manifest or remote manifest override), - // then that package is not considered part of the Unity Editor "product" and we need to let users know. - var unityVersionString = m_Application.unityVersion; - if (m_Version.HasTag(PackageTag.Unity) && !m_Version.HasTag(PackageTag.BuiltIn) && m_Package.versions.recommended == null) - { - UIUtils.SetElementDisplay(versionInfoIcon, true); - versionInfoIcon.tooltip = string.Format(L10n.Tr("This package is not officially supported for Unity {0}."), unityVersionString); - return; - } - - // We want to let users know when they are using a version different than the recommended. - // However, we don't want to show the info icon if the version currently installed - // is a higher patch version of the one in the editor manifest (still considered recommended). - var recommended = m_Package.versions.recommended; - if (m_Version.isInstalled - && m_Package.state != PackageState.InstalledAsDependency - && m_Version.HasTag(PackageTag.Unity) - && recommended != null - && installed.version?.IsEqualOrPatchOf(recommended.version) != true) - { - UIUtils.SetElementDisplay(versionInfoIcon, true); - versionInfoIcon.tooltip = string.Format(L10n.Tr("This version is not the recommended for Unity {0}. The recommended version is {1}."), - unityVersionString, recommended.versionString); - return; - } - - UIUtils.SetElementDisplay(versionInfoIcon, false); - } - private bool TryShowAuthorLink() { authorContainer.Clear(); @@ -345,7 +299,7 @@ private void RefreshRegistryAndAuthor() private SelectableLabel detailTitle => cache.Get("detailTitle"); private Label detailEntitlement => cache.Get