From 1af5177c02cff7745c480b1145b5daa26d2a5a17 Mon Sep 17 00:00:00 2001 From: Nico de Poel Date: Fri, 22 Aug 2025 12:44:48 +0200 Subject: [PATCH] Auto-sync from SVN revision 64833 --- .../Runtime/AnimationRig/RigBuilder.cs | 1 + .../ProbeVolume/ProbeVolumeLightingTab.cs | 3 + .../Editor/MaterialUpgrader.cs | 2 + .../Editor/RenderGraph/RenderGraphViewer.cs | 6 ++ .../SampleDependencyImporter.cs | 19 +++-- .../Volume/VolumeComponentListEditor.cs | 7 +- .../Runtime/GPUDriven/InstanceCuller.cs | 8 +- .../Compiler/NativePassCompiler.cs | 11 ++- .../Runtime/Volume/Volume.cs | 1 + .../Runtime/Volume/Volume.cs.meta | 2 +- .../Runtime/Volume/VolumeProfile.cs | 32 ++++++-- .../Tests/Runtime/VolumeComponents.meta | 8 ++ .../package.json | 2 +- .../RenderPipeline/RenderPass/FSR2Pass.cs | 10 ++- .../Water/Shaders/SampleWaterSurface.hlsl | 37 +++++---- .../package.json | 2 +- Packages/com.unity.shadergraph/package.json | 2 +- .../Editor/UGUI/UI/ImageEditor.cs | 2 +- .../Runtime/TMP/TMP_FontAssetUtilities.cs | 14 ++-- .../com.unity.ugui/Runtime/TMP/TMP_Text.cs | 76 +++++++++---------- .../Runtime/UGUI/UI/Core/Graphic.cs | 14 +++- .../Runtime/UGUI/UI/Core/MaskableGraphic.cs | 3 + .../Tests/Runtime/UGUI/Graphic/ImageTests.cs | 24 ++++++ Packages/com.unity.ugui/package.json | 2 +- .../com.unity.visualeffectgraph/package.json | 2 +- 25 files changed, 190 insertions(+), 100 deletions(-) create mode 100644 Packages/com.unity.render-pipelines.core/Tests/Runtime/VolumeComponents.meta diff --git a/Packages/com.unity.animation.rigging/Runtime/AnimationRig/RigBuilder.cs b/Packages/com.unity.animation.rigging/Runtime/AnimationRig/RigBuilder.cs index 04271c2d..6539f53a 100644 --- a/Packages/com.unity.animation.rigging/Runtime/AnimationRig/RigBuilder.cs +++ b/Packages/com.unity.animation.rigging/Runtime/AnimationRig/RigBuilder.cs @@ -12,6 +12,7 @@ namespace UnityEngine.Animations.Rigging [RequireComponent(typeof(Animator))] [DisallowMultipleComponent, ExecuteInEditMode, AddComponentMenu("Animation Rigging/Setup/Rig Builder")] [HelpURL("https://docs.unity3d.com/Packages/com.unity.animation.rigging@1.3/manual/RiggingWorkflow.html#rig-builder-component")] + [DefaultExecutionOrder(9999)] public class RigBuilder : MonoBehaviour, IAnimationWindowPreview, IRigEffectorHolder { [SerializeField] private List m_RigLayers; diff --git a/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeVolumeLightingTab.cs b/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeVolumeLightingTab.cs index 4e087fe4..b7d5271d 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeVolumeLightingTab.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeVolumeLightingTab.cs @@ -964,6 +964,9 @@ namespace UnityEngine.Rendering if (!prv.isInitialized || !prv.enabledBySRP) return false; + // Always baking with a fresh activeSet + activeSet = null; + // In case UI was never opened we have to setup some stuff FindActiveSet(); diff --git a/Packages/com.unity.render-pipelines.core/Editor/MaterialUpgrader.cs b/Packages/com.unity.render-pipelines.core/Editor/MaterialUpgrader.cs index d5aae4ee..de184176 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/MaterialUpgrader.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/MaterialUpgrader.cs @@ -632,6 +632,8 @@ namespace UnityEditor.Rendering lastMaterialName = material.name; } + AssetDatabase.SaveAssets(); + UnityEditor.EditorUtility.ClearProgressBar(); } } diff --git a/Packages/com.unity.render-pipelines.core/Editor/RenderGraph/RenderGraphViewer.cs b/Packages/com.unity.render-pipelines.core/Editor/RenderGraph/RenderGraphViewer.cs index bdd225a4..fc58fb6b 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/RenderGraph/RenderGraphViewer.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/RenderGraph/RenderGraphViewer.cs @@ -1916,12 +1916,18 @@ namespace UnityEditor.Rendering void OnGraphRegistered(RenderGraph graph) { + if (m_RegisteredGraphs.ContainsKey(graph)) + return; + m_RegisteredGraphs.Add(graph, new HashSet()); RebuildHeaderUI(); } void OnGraphUnregistered(RenderGraph graph) { + if (!m_RegisteredGraphs.ContainsKey(graph)) + return; + m_RegisteredGraphs.Remove(graph); RebuildHeaderUI(); if (m_RegisteredGraphs.Count == 0) diff --git a/Packages/com.unity.render-pipelines.core/Editor/SampleDependencyImportSystem/SampleDependencyImporter.cs b/Packages/com.unity.render-pipelines.core/Editor/SampleDependencyImportSystem/SampleDependencyImporter.cs index 64f37596..734e122d 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/SampleDependencyImportSystem/SampleDependencyImporter.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/SampleDependencyImportSystem/SampleDependencyImporter.cs @@ -8,7 +8,7 @@ using UnityEngine.UIElements; using PackageInfo = UnityEditor.PackageManager.PackageInfo; /// -/// To implement this, the package needs to starts with k_srpPrefixPackage +/// To implement this, the package needs to be in the allowedPackageList /// Then, in the package.json, an array can be added after the path variable of the sample. The path should start from the Packages/ folder, as such: /// "samples": [ /// { @@ -128,13 +128,11 @@ class SampleDependencyImporter : IPackageManagerExtension /// void LoadAssetDependencies(string assetPath) { - - ImportTextMeshProEssentialResources(); - if (m_SampleList != null) { var assetsImported = false; - + bool atLeastOneIsSampleDirectory = false; + for (int i = 0; i < m_Samples.Count; ++i) { string pathPrefix = $"Assets/Samples/{m_PackageInfo.displayName}/{m_PackageInfo.version}/"; @@ -143,18 +141,23 @@ class SampleDependencyImporter : IPackageManagerExtension var isSampleDirectory = assetPath.EndsWith(m_Samples[i].displayName) && assetPath.StartsWith(pathPrefix); if (isSampleDirectory) { + atLeastOneIsSampleDirectory = true; + // Retrieving the dependencies of the sample that is currently being imported. SampleInformation currentSampleInformation = GetSampleInformation(m_Samples[i].displayName); if (currentSampleInformation != null) { // Import the common asset dependencies - assetsImported = ImportDependencies(m_PackageInfo, currentSampleInformation.dependencies); + assetsImported = ImportDependencies(m_PackageInfo, currentSampleInformation.dependencies); } } } - - + + // Only import TMPro resources if a sample is currently imported. + // This is done outside the loop to save cost. + if (atLeastOneIsSampleDirectory) + ImportTextMeshProEssentialResources(); if (assetsImported) AssetDatabase.Refresh(); diff --git a/Packages/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentListEditor.cs b/Packages/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentListEditor.cs index 36eebd1b..69af1c4d 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentListEditor.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentListEditor.cs @@ -236,11 +236,14 @@ namespace UnityEditor.Rendering // Even if the asset is not dirty, the list of component may have been changed by another inspector. // In this case, only the hash will tell us that we need to refresh. - if (asset.isDirty || asset.GetComponentListHashCode() != m_CurrentHashCode) + if (asset.dirtyState != VolumeProfile.DirtyState.None || asset.GetComponentListHashCode() != m_CurrentHashCode) { RefreshEditors(); VolumeManager.instance.OnVolumeProfileChanged(asset); - asset.isDirty = false; + + if ((asset.dirtyState & VolumeProfile.DirtyState.DirtyByProfileReset) != 0) + UnityEditorInternal.InternalEditorUtility.RepaintAllViews(); + asset.dirtyState = VolumeProfile.DirtyState.None; } if (m_IsDefaultVolumeProfile && VolumeManager.instance.isInitialized && m_EditorsByCategory.Count == 0) diff --git a/Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/InstanceCuller.cs b/Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/InstanceCuller.cs index ce248771..390c7b24 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/InstanceCuller.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/InstanceCuller.cs @@ -403,11 +403,11 @@ namespace UnityEngine.Rendering private uint ComputeMeshLODLevel(int instanceIndex, int sharedInstanceIndex) { ref readonly GPUDrivenRendererMeshLodData meshLodData = ref instanceData.meshLodData.UnsafeElementAt(instanceIndex); + var meshLodInfo = sharedInstanceData.meshLodInfos[sharedInstanceIndex]; if (meshLodData.forceLod >= 0) - return (uint)meshLodData.forceLod; + return (uint)math.clamp(meshLodData.forceLod, 0, meshLodInfo.levelCount - 1); - var levelInfo = sharedInstanceData.meshLodInfos[sharedInstanceIndex]; ref readonly AABB worldAABB = ref instanceData.worldAABBs.UnsafeElementAt(instanceIndex); var radiusSqr = math.max(math.lengthsq(worldAABB.extents), 1e-5f); @@ -417,13 +417,13 @@ namespace UnityEngine.Rendering var boundsDesiredPercentage = Math.Sqrt(cameraSqrHeightAtDistance / diameterSqr); - var levelIndexFlt = math.log2(boundsDesiredPercentage) * levelInfo.lodSlope + levelInfo.lodBias; + var levelIndexFlt = math.log2(boundsDesiredPercentage) * meshLodInfo.lodSlope + meshLodInfo.lodBias; // We apply Bias after max to enforce that a positive bias of +N we would select lodN instead of Lod0 levelIndexFlt = math.max(levelIndexFlt, 0); levelIndexFlt += meshLodData.lodSelectionBias; - levelIndexFlt = math.clamp(levelIndexFlt,0, levelInfo.levelCount - 1); + levelIndexFlt = math.clamp(levelIndexFlt, 0, meshLodInfo.levelCount - 1); return (uint)math.floor(levelIndexFlt); } diff --git a/Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/Compiler/NativePassCompiler.cs b/Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/Compiler/NativePassCompiler.cs index 86824d15..b0cabb54 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/Compiler/NativePassCompiler.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/Compiler/NativePassCompiler.cs @@ -748,21 +748,24 @@ namespace UnityEngine.Rendering.RenderGraphModule.NativeRenderPassCompiler foreach (ref readonly var res in subPass.FirstUsedResources(contextData)) { ref readonly var resInfo = ref contextData.UnversionedResourceData(res); + bool usedAsFragmentThisPass = subPass.IsUsedAsFragment(res, contextData); + + // This resource is read for the first time as a regular texture and not as a framebuffer attachment + // so if requested we need to explicitly clear it, as loadAction.clear only works on framebuffer attachments + resources.forceManualClearOfResource = !usedAsFragmentThisPass; + if (!resInfo.memoryLess) { if (!resInfo.isImported) { - bool usedAsFragmentThisPass = subPass.IsUsedAsFragment(res, contextData); - // This resource is read for the first time as a regular texture and not as a framebuffer attachment // so we need to explicitly clear it, as loadAction.clear only works on framebuffer attachments // TODO: Should this be a performance warning?? Maybe rare enough in practice? - resources.forceManualClearOfResource = !usedAsFragmentThisPass; resources.CreatePooledResource(rgContext, res.iType, res.index); } else // Imported resource { - if (resInfo.clear) + if (resInfo.clear && resources.forceManualClearOfResource) resources.ClearResource(rgContext, res.iType, res.index); } } diff --git a/Packages/com.unity.render-pipelines.core/Runtime/Volume/Volume.cs b/Packages/com.unity.render-pipelines.core/Runtime/Volume/Volume.cs index ebb8a8e1..88c36382 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/Volume/Volume.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/Volume/Volume.cs @@ -11,6 +11,7 @@ namespace UnityEngine.Rendering [PipelineHelpURL("UniversalRenderPipelineAsset", "Volumes")] [ExecuteAlways] [AddComponentMenu("Miscellaneous/Volume")] + [Icon("Packages/com.unity.render-pipelines.core/Editor/Icons/Processed/Volume Icon.asset")] public class Volume : MonoBehaviour, IVolume { [SerializeField, FormerlySerializedAs("isGlobal")] diff --git a/Packages/com.unity.render-pipelines.core/Runtime/Volume/Volume.cs.meta b/Packages/com.unity.render-pipelines.core/Runtime/Volume/Volume.cs.meta index e59941be..e3aa1d2d 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/Volume/Volume.cs.meta +++ b/Packages/com.unity.render-pipelines.core/Runtime/Volume/Volume.cs.meta @@ -5,7 +5,7 @@ MonoImporter: serializedVersion: 2 defaultReferences: [] executionOrder: 0 - icon: {fileID: 2800000, guid: 32b23d5d74f3aee4f9364e34e2f59379, type: 3} + icon: {instanceID: 0} userData: assetBundleName: assetBundleVariant: diff --git a/Packages/com.unity.render-pipelines.core/Runtime/Volume/VolumeProfile.cs b/Packages/com.unity.render-pipelines.core/Runtime/Volume/VolumeProfile.cs index 6b15949c..53d2a302 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/Volume/VolumeProfile.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/Volume/VolumeProfile.cs @@ -23,8 +23,28 @@ namespace UnityEngine.Rendering /// A dirty check used to redraw the profile inspector when something has changed. This is /// currently only used in the editor. /// - [NonSerialized] - public bool isDirty = true; // Editor only, doesn't have any use outside of it + [Obsolete("This field was only public for editor access. #from(6000.0)")] + public bool isDirty + { + get => dirtyState != DirtyState.None; + set + { + if (value) + dirtyState |= DirtyState.Other; + else + dirtyState &= ~DirtyState.Other; + } + } + + [Flags] internal enum DirtyState + { + None = 0, + DirtyByComponentChange = 1, + DirtyByProfileReset = 2, + Other = 4 + } + + internal DirtyState dirtyState; void OnEnable() { @@ -56,9 +76,7 @@ namespace UnityEngine.Rendering /// Volume Profile editor when you modify the Asset via script instead of the Inspector. /// public void Reset() - { - isDirty = true; - } + => dirtyState |= DirtyState.DirtyByProfileReset; /// /// Adds a to this Volume Profile. @@ -100,7 +118,7 @@ namespace UnityEngine.Rendering #endif component.SetAllOverridesTo(overrides); components.Add(component); - isDirty = true; + dirtyState |= DirtyState.DirtyByComponentChange; return component; } @@ -142,7 +160,7 @@ namespace UnityEngine.Rendering if (toRemove >= 0) { components.RemoveAt(toRemove); - isDirty = true; + dirtyState |= DirtyState.DirtyByComponentChange; } } diff --git a/Packages/com.unity.render-pipelines.core/Tests/Runtime/VolumeComponents.meta b/Packages/com.unity.render-pipelines.core/Tests/Runtime/VolumeComponents.meta new file mode 100644 index 00000000..71837c63 --- /dev/null +++ b/Packages/com.unity.render-pipelines.core/Tests/Runtime/VolumeComponents.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d7a8435b968e9714c9ea91e7101c3e03 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.render-pipelines.core/package.json b/Packages/com.unity.render-pipelines.core/package.json index ae301b0c..eaa812d2 100644 --- a/Packages/com.unity.render-pipelines.core/package.json +++ b/Packages/com.unity.render-pipelines.core/package.json @@ -14,5 +14,5 @@ "com.unity.modules.jsonserialize": "1.0.0", "com.unity.rendering.light-transport": "1.0.1" }, - "_fingerprint": "bd0e8186c2bcfea109ee5981b813a1b39a6382fb" + "_fingerprint": "609b19816fd255e06290637a743a23085dbde6de" } diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/FSR2Pass.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/FSR2Pass.cs index 37bd79ee..3e6273e4 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/FSR2Pass.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/FSR2Pass.cs @@ -30,9 +30,15 @@ namespace UnityEngine.Rendering.HighDefinition Debug.LogWarning("Cannot instantiate AMD device because the version HDRP expects does not match the backend version."); return false; } + + bool deviceReady = AMD.GraphicsDevice.device != null; + if (!deviceReady) + { + AMD.GraphicsDevice.CreateGraphicsDevice(); + deviceReady = AMD.GraphicsDevice.device != null; + } - AMD.GraphicsDevice device = AMD.GraphicsDevice.CreateGraphicsDevice(); - return device != null; + return deviceReady; #else return false; #endif diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/Water/Shaders/SampleWaterSurface.hlsl b/Packages/com.unity.render-pipelines.high-definition/Runtime/Water/Shaders/SampleWaterSurface.hlsl index 082ba048..fb09f498 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/Water/Shaders/SampleWaterSurface.hlsl +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/Water/Shaders/SampleWaterSurface.hlsl @@ -302,7 +302,7 @@ void EvaluateDisplacement(float3 positionOS, float3 verticalDisplacements, out f #if defined(SUPPORT_WATER_DEFORMATION) // Apply the deformation data - float4 deformation = EvaluateWaterDeformation(positionAWS + verticalDisplacements); + float4 deformation = EvaluateWaterDeformation(positionAWS); horizontalDisplacement = deformation.yz; verticalDisplacement += deformation.x; lowFrequencyHeight += deformation.x; @@ -317,18 +317,20 @@ struct WaterDisplacementData void EvaluateWaterDisplacement(float3 positionOS, out WaterDisplacementData displacementData) { - float2 simulationHorizontalDisplacement; - float2 deformationHorizontalDisplacement; - float3 verticalDisplacements; - EvaluateSimulationDisplacement(positionOS, simulationHorizontalDisplacement, verticalDisplacements); - + // This is a float 3 because there's one displacement per frequency band. + float3 simulationVerticalDisplacements; + float2 simulationHorizontalDisplacement; + + EvaluateSimulationDisplacement(positionOS, simulationHorizontalDisplacement, simulationVerticalDisplacements); + + // Out parameters to evaluate deformation displacement. + float deformationVerticalDisplacement; + float2 deformationHorizontalDisplacement; float lowFrequencyHeight; - float3 displacement = float3(simulationHorizontalDisplacement.x, 0, simulationHorizontalDisplacement.y); - EvaluateDisplacement(positionOS + displacement, verticalDisplacements, displacement.y, deformationHorizontalDisplacement, lowFrequencyHeight); + EvaluateDisplacement(positionOS, simulationVerticalDisplacements, deformationVerticalDisplacement, deformationHorizontalDisplacement, lowFrequencyHeight); - displacement.xz += deformationHorizontalDisplacement.xy; - - displacementData.displacement = displacement; + // Simulation displacement is not included in the displacement to avoid having water decal effects move with the waves if the distand wind is high. + displacementData.displacement = float3(deformationHorizontalDisplacement.x, deformationVerticalDisplacement, deformationHorizontalDisplacement.y); displacementData.lowFrequencyHeight = lowFrequencyHeight; #if defined(SHADER_STAGE_VERTEX) && !defined(WATER_DISPLACEMENT) @@ -435,22 +437,17 @@ void SampleSimulation_PS(WaterSimCoord waterCoord, float3 waterMask, float dista } } -void EvaluateWaterAdditionalData(float3 positionOS, float3 transformedPosition, float3 meshNormalOS, float2 horizontalDisplacement, out WaterAdditionalData waterAdditionalData) +void EvaluateWaterAdditionalData(float3 positionOS, float3 positionRWS, float3 meshNormalOS, float2 horizontalDisplacement, out WaterAdditionalData waterAdditionalData) { ZERO_INITIALIZE(WaterAdditionalData, waterAdditionalData); if (_GridSize.x < 0) return; - // Evaluate the pre-displaced absolute position -#if defined(WATER_DISPLACEMENT) - float3 positionRWS = positionOS; -#else - float3 positionRWS = TransformObjectToWorld_Water(positionOS); -#endif - // Evaluate the distance to the camera + // Evaluate the distance to the camera. used only if WATER_DISPLACEMENT is defined. float distanceToCamera = length(positionRWS); + // Get the world space transformed postion - float3 transformedAWS = GetAbsolutePositionWS(transformedPosition); + float3 transformedAWS = GetAbsolutePositionWS(positionRWS); float2 decalUV = EvaluateDecalUV(transformedAWS - float3(horizontalDisplacement.x, 0.0f, horizontalDisplacement.y)); // Compute the texture size param for the filtering diff --git a/Packages/com.unity.render-pipelines.high-definition/package.json b/Packages/com.unity.render-pipelines.high-definition/package.json index 16bf5c81..dc33b28e 100644 --- a/Packages/com.unity.render-pipelines.high-definition/package.json +++ b/Packages/com.unity.render-pipelines.high-definition/package.json @@ -100,5 +100,5 @@ ] } ], - "_fingerprint": "28765669b6fee79d765751f370129f832b2c30c4" + "_fingerprint": "334d0e60f4bcdab1b4738903568de1a76a51824d" } diff --git a/Packages/com.unity.shadergraph/package.json b/Packages/com.unity.shadergraph/package.json index 9c9469c3..ec820a1e 100644 --- a/Packages/com.unity.shadergraph/package.json +++ b/Packages/com.unity.shadergraph/package.json @@ -48,5 +48,5 @@ "path": "Samples~/CustomMaterialPropertyDrawers" } ], - "_fingerprint": "f8b69e83dfddc9d7bbdcb1b4c60f079ffee88676" + "_fingerprint": "844e9247af8212b592252c83949e35127bce08e9" } diff --git a/Packages/com.unity.ugui/Editor/UGUI/UI/ImageEditor.cs b/Packages/com.unity.ugui/Editor/UGUI/UI/ImageEditor.cs index 2d8b5fe0..5a08a971 100644 --- a/Packages/com.unity.ugui/Editor/UGUI/UI/ImageEditor.cs +++ b/Packages/com.unity.ugui/Editor/UGUI/UI/ImageEditor.cs @@ -235,7 +235,7 @@ namespace UnityEditor.UI if (EditorGUILayout.BeginFadeGroup(m_ShowTiled.faded)) { if (image.sprite != null && !image.hasBorder && (image.sprite.texture != null && image.sprite.texture.wrapMode != TextureWrapMode.Repeat || image.sprite.packed)) - EditorGUILayout.HelpBox("It looks like you want to tile a sprite with no border. It would be more efficient to modify the Sprite properties, clear the Packing tag and set the Wrap mode to Repeat.", MessageType.Warning); + EditorGUILayout.HelpBox("It looks like you want to tile a sprite with no border. It would be more efficient to remove this Sprite from any SpriteAtlas and set the Wrap mode to Repeat.", MessageType.Warning); } EditorGUILayout.EndFadeGroup(); diff --git a/Packages/com.unity.ugui/Runtime/TMP/TMP_FontAssetUtilities.cs b/Packages/com.unity.ugui/Runtime/TMP/TMP_FontAssetUtilities.cs index f0e2c086..d142c579 100644 --- a/Packages/com.unity.ugui/Runtime/TMP/TMP_FontAssetUtilities.cs +++ b/Packages/com.unity.ugui/Runtime/TMP/TMP_FontAssetUtilities.cs @@ -73,7 +73,7 @@ namespace TMPro if (isItalic || fontWeight != FontWeight.Regular) { - // Check if character is already cached using the composite Unicode value the takes into consideration the font style and weight + // Check if character is already cached using the composite Unicode value that takes into consideration the font style and weight uint compositeUnicodeLookupKey = ((0x80u | ((uint)fontStyle << 4) | ((uint)fontWeight / 100)) << 24) | unicode; if (sourceFontAsset.characterLookupTable.TryGetValue(compositeUnicodeLookupKey, out character)) { @@ -138,7 +138,7 @@ namespace TMPro temp.characterLookupTable.Remove(unicode); } - if (temp.atlasPopulationMode == AtlasPopulationMode.Dynamic || temp.atlasPopulationMode == AtlasPopulationMode.DynamicOS) + if (temp.atlasPopulationMode is AtlasPopulationMode.Dynamic or AtlasPopulationMode.DynamicOS) { if (temp.TryAddCharacterInternal(unicode, out character)) { @@ -150,7 +150,7 @@ namespace TMPro } // Search potential fallbacks of the source font asset - if (includeFallbacks && sourceFontAsset.fallbackFontAssetTable != null) + if (includeFallbacks && sourceFontAsset.fallbackFontAssetTable is { Count: > 0 }) return SearchFallbacksForCharacter(unicode, sourceFontAsset, fontStyle, fontWeight, out isAlternativeTypeface); return null; @@ -167,14 +167,14 @@ namespace TMPro sourceFontAsset.characterLookupTable.Remove(unicode); } - if (sourceFontAsset.atlasPopulationMode == AtlasPopulationMode.Dynamic || sourceFontAsset.atlasPopulationMode == AtlasPopulationMode.DynamicOS) + if (sourceFontAsset.atlasPopulationMode is AtlasPopulationMode.Dynamic or AtlasPopulationMode.DynamicOS) { if (sourceFontAsset.TryAddCharacterInternal(unicode, out character)) return character; } - // Search fallback font assets if we still don't have a valid character and include fallback is set to true. - if (includeFallbacks && sourceFontAsset.fallbackFontAssetTable != null) + // Search fallback font assets if we still don't have a valid character and include fallbacks is set to true. + if (includeFallbacks && sourceFontAsset.fallbackFontAssetTable is { Count: > 0 }) return SearchFallbacksForCharacter(unicode, sourceFontAsset, fontStyle, fontWeight, out isAlternativeTypeface); return null; @@ -200,7 +200,7 @@ namespace TMPro int id = temp.instanceID; - // Try adding font asset to search list. If already present skip to the next one otherwise check if it contains the requested character. + // Try adding font asset to the search list. If already present, skip to the next one otherwise check if it contains the requested character. if (k_SearchedAssets.Add(id) == false) continue; diff --git a/Packages/com.unity.ugui/Runtime/TMP/TMP_Text.cs b/Packages/com.unity.ugui/Runtime/TMP/TMP_Text.cs index 25e1857d..e38c9e6b 100644 --- a/Packages/com.unity.ugui/Runtime/TMP/TMP_Text.cs +++ b/Packages/com.unity.ugui/Runtime/TMP/TMP_Text.cs @@ -6140,6 +6140,44 @@ namespace TMPro } } + // Since we have been unable to locate the character thus far using the designated font style and weight. Attempt to locate this character using normal style and regular font weight to synthesize it. + if (fontStyle != FontStyles.Normal || fontWeight != FontWeight.Regular) + { + character = TMP_FontAssetUtilities.GetCharacterFromFontAsset(unicode, fontAsset, true, FontStyles.Normal, FontWeight.Regular, out isUsingAlternativeTypeface); + + if (character != null) + { + // Add character to font asset lookup cache + fontAsset.AddCharacterToLookupCache(unicode, character, FontStyles.Normal, FontWeight.Regular, isUsingAlternativeTypeface); + + return character; + } + + // Search potential Global fallback font assets. + if (TMP_Settings.fallbackFontAssets != null && TMP_Settings.fallbackFontAssets.Count > 0) + character = TMP_FontAssetUtilities.GetCharacterFromFontAssets(unicode, fontAsset, TMP_Settings.fallbackFontAssets, true, FontStyles.Normal, FontWeight.Regular, out isUsingAlternativeTypeface); + + if (character != null) + { + // Add character to font asset lookup cache + fontAsset.AddCharacterToLookupCache(unicode, character, FontStyles.Normal, FontWeight.Regular, isUsingAlternativeTypeface); + + return character; + } + + // Search for the character in the Default Font Asset assigned in the TMP Settings file. + if (TMP_Settings.defaultFontAsset != null) + character = TMP_FontAssetUtilities.GetCharacterFromFontAsset(unicode, TMP_Settings.defaultFontAsset, true, FontStyles.Normal, FontWeight.Regular, out isUsingAlternativeTypeface); + + if (character != null) + { + // Add character to font asset lookup cache + fontAsset.AddCharacterToLookupCache(unicode, character, FontStyles.Normal, FontWeight.Regular, isUsingAlternativeTypeface); + + return character; + } + } + // Search for the character in potential local Sprite Asset assigned to the text object. if (m_spriteAsset != null) { @@ -6182,44 +6220,6 @@ namespace TMPro return spriteCharacter; } - // Since we have been unable to locate the character thus far using the designated font style and weight. Attempt to locate this character using normal style and regular font weight in order to synthesize it. - if (fontStyle != FontStyles.Normal || fontWeight != FontWeight.Regular) - { - character = TMP_FontAssetUtilities.GetCharacterFromFontAsset(unicode, fontAsset, true, FontStyles.Normal, FontWeight.Regular, out isUsingAlternativeTypeface); - - if (character != null) - { - // Add character to font asset lookup cache - fontAsset.AddCharacterToLookupCache(unicode, character, FontStyles.Normal, FontWeight.Regular, isUsingAlternativeTypeface); - - return character; - } - - // Search potential Global fallback font assets. - if (TMP_Settings.fallbackFontAssets != null && TMP_Settings.fallbackFontAssets.Count > 0) - character = TMP_FontAssetUtilities.GetCharacterFromFontAssets(unicode, fontAsset, TMP_Settings.fallbackFontAssets, true, FontStyles.Normal, FontWeight.Regular, out isUsingAlternativeTypeface); - - if (character != null) - { - // Add character to font asset lookup cache - fontAsset.AddCharacterToLookupCache(unicode, character, FontStyles.Normal, FontWeight.Regular, isUsingAlternativeTypeface); - - return character; - } - - // Search for the character in the Default Font Asset assigned in the TMP Settings file. - if (TMP_Settings.defaultFontAsset != null) - character = TMP_FontAssetUtilities.GetCharacterFromFontAsset(unicode, TMP_Settings.defaultFontAsset, true, FontStyles.Normal, FontWeight.Regular, out isUsingAlternativeTypeface); - - if (character != null) - { - // Add character to font asset lookup cache - fontAsset.AddCharacterToLookupCache(unicode, character, FontStyles.Normal, FontWeight.Regular, isUsingAlternativeTypeface); - - return character; - } - } - return null; } diff --git a/Packages/com.unity.ugui/Runtime/UGUI/UI/Core/Graphic.cs b/Packages/com.unity.ugui/Runtime/UGUI/UI/Core/Graphic.cs index 664caefd..8a1fe9ac 100644 --- a/Packages/com.unity.ugui/Runtime/UGUI/UI/Core/Graphic.cs +++ b/Packages/com.unity.ugui/Runtime/UGUI/UI/Core/Graphic.cs @@ -839,7 +839,16 @@ namespace UnityEngine.UI /// Screen point being tested /// Camera that is being used for the testing. /// True if the provided point is a valid location for GraphicRaycaster raycasts. - public virtual bool Raycast(Vector2 sp, Camera eventCamera) + public virtual bool Raycast(Vector2 sp, Camera eventCamera) => Raycast(sp, eventCamera, false); + + /// + /// When a GraphicRaycaster raycasts into the scene, it first filters the elements based on their RectTransform rect, then uses this Raycast function to determine which elements are hit. + /// + /// Screen point being tested. + /// Camera used for testing. + /// If true, masks are ignored and do not prevent raycasts. + /// True if the provided point is a valid location for GraphicRaycaster raycasts. + protected bool Raycast(Vector2 sp, Camera eventCamera, bool ignoreMasks) { if (!isActiveAndEnabled) return false; @@ -864,6 +873,9 @@ namespace UnityEngine.UI if (filter == null) continue; + if (ignoreMasks && components[i] is Mask or RectMask2D) + continue; + var raycastValid = true; var group = components[i] as CanvasGroup; diff --git a/Packages/com.unity.ugui/Runtime/UGUI/UI/Core/MaskableGraphic.cs b/Packages/com.unity.ugui/Runtime/UGUI/UI/Core/MaskableGraphic.cs index efe04ac3..f5428eff 100644 --- a/Packages/com.unity.ugui/Runtime/UGUI/UI/Core/MaskableGraphic.cs +++ b/Packages/com.unity.ugui/Runtime/UGUI/UI/Core/MaskableGraphic.cs @@ -300,5 +300,8 @@ namespace UnityEngine.UI m_ShouldRecalculateStencil = true; SetMaterialDirty(); } + + /// + public override bool Raycast(Vector2 sp, Camera eventCamera) => Raycast(sp, eventCamera, !maskable); } } diff --git a/Packages/com.unity.ugui/Tests/Runtime/UGUI/Graphic/ImageTests.cs b/Packages/com.unity.ugui/Tests/Runtime/UGUI/Graphic/ImageTests.cs index d42b8ce9..24d41709 100644 --- a/Packages/com.unity.ugui/Tests/Runtime/UGUI/Graphic/ImageTests.cs +++ b/Packages/com.unity.ugui/Tests/Runtime/UGUI/Graphic/ImageTests.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using NUnit.Framework; +using UnityEngine.EventSystems; namespace UnityEngine.UI.Tests { @@ -160,6 +161,29 @@ namespace UnityEngine.UI.Tests Assert.IsTrue(raycast); } + [TestCase(typeof(Mask), true, false)] + [TestCase(typeof(Mask), false, true)] + [TestCase(typeof(RectMask2D), true, false)] + [TestCase(typeof(RectMask2D), false, true)] + public void RaycastImageOutsideOfMaskWithMaskableSet_ReturnsExpected(Type maskType, bool maskable, bool expectedHit) + { + var maskGameObject = new GameObject("Mask", typeof(RectTransform), maskType); + maskGameObject.transform.SetParent(m_CanvasRoot.transform); + var mask = maskGameObject.GetComponent(maskType); + m_Image.transform.SetParent(maskGameObject.transform); + + var maskRect = mask.GetComponent(); + maskRect.position = new Vector3(0, 0, 0); + maskRect.sizeDelta = new Vector2(100, 100); + m_Image.rectTransform.position = new Vector3(500, 500, 0); + m_Image.rectTransform.sizeDelta = new Vector2(10, 10); + + m_Image.maskable = maskable; + + bool raycast = m_Image.Raycast(new Vector2(505, 505), m_camera); + Assert.AreEqual(expectedHit, raycast); + } + [Test] public void SettingSpriteMarksAllAsDirty() { diff --git a/Packages/com.unity.ugui/package.json b/Packages/com.unity.ugui/package.json index 737f599e..609f8490 100644 --- a/Packages/com.unity.ugui/package.json +++ b/Packages/com.unity.ugui/package.json @@ -19,5 +19,5 @@ "com.unity.modules.ui": "1.0.0", "com.unity.modules.imgui": "1.0.0" }, - "_fingerprint": "423bc642aff1ba4fed4feef1d7b45461138cbb32" + "_fingerprint": "80da3b035d6b6df2ec3900d3eb384a0a4e79cffd" } diff --git a/Packages/com.unity.visualeffectgraph/package.json b/Packages/com.unity.visualeffectgraph/package.json index 38113e06..e2d87558 100644 --- a/Packages/com.unity.visualeffectgraph/package.json +++ b/Packages/com.unity.visualeffectgraph/package.json @@ -36,5 +36,5 @@ ] } ], - "_fingerprint": "c8dcb84572f2d0cfeef21465bb35296970fa0aa9" + "_fingerprint": "892d901f7a6641b3aa92b7920acf1d0fc38a0b95" }