Browse Source

Merge branch 'master' into ww1dev/hdrp17/staging

ww1dev/hdrp17/staging
Nico de Poel 5 months ago
parent
commit
d661359f57
  1. 3
      Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeVolumeLightingTab.cs
  2. 2
      Packages/com.unity.render-pipelines.core/Editor/MaterialUpgrader.cs
  3. 6
      Packages/com.unity.render-pipelines.core/Editor/RenderGraph/RenderGraphViewer.cs
  4. 19
      Packages/com.unity.render-pipelines.core/Editor/SampleDependencyImportSystem/SampleDependencyImporter.cs
  5. 7
      Packages/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentListEditor.cs
  6. 8
      Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/InstanceCuller.cs
  7. 11
      Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/Compiler/NativePassCompiler.cs
  8. 1
      Packages/com.unity.render-pipelines.core/Runtime/Volume/Volume.cs
  9. 2
      Packages/com.unity.render-pipelines.core/Runtime/Volume/Volume.cs.meta
  10. 32
      Packages/com.unity.render-pipelines.core/Runtime/Volume/VolumeProfile.cs
  11. 2
      Packages/com.unity.render-pipelines.core/package.json
  12. 10
      Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/FSR2Pass.cs
  13. 37
      Packages/com.unity.render-pipelines.high-definition/Runtime/Water/Shaders/SampleWaterSurface.hlsl
  14. 2
      Packages/com.unity.render-pipelines.high-definition/package.json
  15. 2
      Packages/com.unity.shadergraph/package.json
  16. 2
      Packages/com.unity.ugui/Editor/UGUI/UI/ImageEditor.cs
  17. 14
      Packages/com.unity.ugui/Runtime/TMP/TMP_FontAssetUtilities.cs
  18. 76
      Packages/com.unity.ugui/Runtime/TMP/TMP_Text.cs
  19. 14
      Packages/com.unity.ugui/Runtime/UGUI/UI/Core/Graphic.cs
  20. 3
      Packages/com.unity.ugui/Runtime/UGUI/UI/Core/MaskableGraphic.cs
  21. 24
      Packages/com.unity.ugui/Tests/Runtime/UGUI/Graphic/ImageTests.cs
  22. 2
      Packages/com.unity.ugui/package.json
  23. 2
      Packages/com.unity.visualeffectgraph/package.json

3
Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeVolumeLightingTab.cs

@ -964,6 +964,9 @@ namespace UnityEngine.Rendering
if (!prv.isInitialized || !prv.enabledBySRP) if (!prv.isInitialized || !prv.enabledBySRP)
return false; return false;
// Always baking with a fresh activeSet
activeSet = null;
// In case UI was never opened we have to setup some stuff // In case UI was never opened we have to setup some stuff
FindActiveSet(); FindActiveSet();

2
Packages/com.unity.render-pipelines.core/Editor/MaterialUpgrader.cs

@ -632,6 +632,8 @@ namespace UnityEditor.Rendering
lastMaterialName = material.name; lastMaterialName = material.name;
} }
AssetDatabase.SaveAssets();
UnityEditor.EditorUtility.ClearProgressBar(); UnityEditor.EditorUtility.ClearProgressBar();
} }
} }

6
Packages/com.unity.render-pipelines.core/Editor/RenderGraph/RenderGraphViewer.cs

@ -1916,12 +1916,18 @@ namespace UnityEditor.Rendering
void OnGraphRegistered(RenderGraph graph) void OnGraphRegistered(RenderGraph graph)
{ {
if (m_RegisteredGraphs.ContainsKey(graph))
return;
m_RegisteredGraphs.Add(graph, new HashSet<string>()); m_RegisteredGraphs.Add(graph, new HashSet<string>());
RebuildHeaderUI(); RebuildHeaderUI();
} }
void OnGraphUnregistered(RenderGraph graph) void OnGraphUnregistered(RenderGraph graph)
{ {
if (!m_RegisteredGraphs.ContainsKey(graph))
return;
m_RegisteredGraphs.Remove(graph); m_RegisteredGraphs.Remove(graph);
RebuildHeaderUI(); RebuildHeaderUI();
if (m_RegisteredGraphs.Count == 0) if (m_RegisteredGraphs.Count == 0)

19
Packages/com.unity.render-pipelines.core/Editor/SampleDependencyImportSystem/SampleDependencyImporter.cs

@ -8,7 +8,7 @@ using UnityEngine.UIElements;
using PackageInfo = UnityEditor.PackageManager.PackageInfo; using PackageInfo = UnityEditor.PackageManager.PackageInfo;
/// <remarks> /// <remarks>
/// 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: /// 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": [ /// "samples": [
/// { /// {
@ -128,13 +128,11 @@ class SampleDependencyImporter : IPackageManagerExtension
/// </summary> /// </summary>
void LoadAssetDependencies(string assetPath) void LoadAssetDependencies(string assetPath)
{ {
ImportTextMeshProEssentialResources();
if (m_SampleList != null) if (m_SampleList != null)
{ {
var assetsImported = false; var assetsImported = false;
bool atLeastOneIsSampleDirectory = false;
for (int i = 0; i < m_Samples.Count; ++i) for (int i = 0; i < m_Samples.Count; ++i)
{ {
string pathPrefix = $"Assets/Samples/{m_PackageInfo.displayName}/{m_PackageInfo.version}/"; 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); var isSampleDirectory = assetPath.EndsWith(m_Samples[i].displayName) && assetPath.StartsWith(pathPrefix);
if (isSampleDirectory) if (isSampleDirectory)
{ {
atLeastOneIsSampleDirectory = true;
// Retrieving the dependencies of the sample that is currently being imported. // Retrieving the dependencies of the sample that is currently being imported.
SampleInformation currentSampleInformation = GetSampleInformation(m_Samples[i].displayName); SampleInformation currentSampleInformation = GetSampleInformation(m_Samples[i].displayName);
if (currentSampleInformation != null) if (currentSampleInformation != null)
{ {
// Import the common asset dependencies // 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) if (assetsImported)
AssetDatabase.Refresh(); AssetDatabase.Refresh();

7
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. // 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. // 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(); RefreshEditors();
VolumeManager.instance.OnVolumeProfileChanged(asset); 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) if (m_IsDefaultVolumeProfile && VolumeManager.instance.isInitialized && m_EditorsByCategory.Count == 0)

8
Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/InstanceCuller.cs

@ -403,11 +403,11 @@ namespace UnityEngine.Rendering
private uint ComputeMeshLODLevel(int instanceIndex, int sharedInstanceIndex) private uint ComputeMeshLODLevel(int instanceIndex, int sharedInstanceIndex)
{ {
ref readonly GPUDrivenRendererMeshLodData meshLodData = ref instanceData.meshLodData.UnsafeElementAt(instanceIndex); ref readonly GPUDrivenRendererMeshLodData meshLodData = ref instanceData.meshLodData.UnsafeElementAt(instanceIndex);
var meshLodInfo = sharedInstanceData.meshLodInfos[sharedInstanceIndex];
if (meshLodData.forceLod >= 0) 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); ref readonly AABB worldAABB = ref instanceData.worldAABBs.UnsafeElementAt(instanceIndex);
var radiusSqr = math.max(math.lengthsq(worldAABB.extents), 1e-5f); var radiusSqr = math.max(math.lengthsq(worldAABB.extents), 1e-5f);
@ -417,13 +417,13 @@ namespace UnityEngine.Rendering
var boundsDesiredPercentage = Math.Sqrt(cameraSqrHeightAtDistance / diameterSqr); 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 // 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 = math.max(levelIndexFlt, 0);
levelIndexFlt += meshLodData.lodSelectionBias; levelIndexFlt += meshLodData.lodSelectionBias;
levelIndexFlt = math.clamp(levelIndexFlt,0, levelInfo.levelCount - 1);
levelIndexFlt = math.clamp(levelIndexFlt, 0, meshLodInfo.levelCount - 1);
return (uint)math.floor(levelIndexFlt); return (uint)math.floor(levelIndexFlt);
} }

11
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)) foreach (ref readonly var res in subPass.FirstUsedResources(contextData))
{ {
ref readonly var resInfo = ref contextData.UnversionedResourceData(res); 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.memoryLess)
{ {
if (!resInfo.isImported) 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 // 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 // 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? // TODO: Should this be a performance warning?? Maybe rare enough in practice?
resources.forceManualClearOfResource = !usedAsFragmentThisPass;
resources.CreatePooledResource(rgContext, res.iType, res.index); resources.CreatePooledResource(rgContext, res.iType, res.index);
} }
else // Imported resource else // Imported resource
{ {
if (resInfo.clear)
if (resInfo.clear && resources.forceManualClearOfResource)
resources.ClearResource(rgContext, res.iType, res.index); resources.ClearResource(rgContext, res.iType, res.index);
} }
} }

1
Packages/com.unity.render-pipelines.core/Runtime/Volume/Volume.cs

@ -11,6 +11,7 @@ namespace UnityEngine.Rendering
[PipelineHelpURL("UniversalRenderPipelineAsset", "Volumes")] [PipelineHelpURL("UniversalRenderPipelineAsset", "Volumes")]
[ExecuteAlways] [ExecuteAlways]
[AddComponentMenu("Miscellaneous/Volume")] [AddComponentMenu("Miscellaneous/Volume")]
[Icon("Packages/com.unity.render-pipelines.core/Editor/Icons/Processed/Volume Icon.asset")]
public class Volume : MonoBehaviour, IVolume public class Volume : MonoBehaviour, IVolume
{ {
[SerializeField, FormerlySerializedAs("isGlobal")] [SerializeField, FormerlySerializedAs("isGlobal")]

2
Packages/com.unity.render-pipelines.core/Runtime/Volume/Volume.cs.meta

@ -5,7 +5,7 @@ MonoImporter:
serializedVersion: 2 serializedVersion: 2
defaultReferences: [] defaultReferences: []
executionOrder: 0 executionOrder: 0
icon: {fileID: 2800000, guid: 32b23d5d74f3aee4f9364e34e2f59379, type: 3}
icon: {instanceID: 0}
userData: userData:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:

32
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 /// A dirty check used to redraw the profile inspector when something has changed. This is
/// currently only used in the editor. /// currently only used in the editor.
/// </summary> /// </summary>
[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() void OnEnable()
{ {
@ -56,9 +76,7 @@ namespace UnityEngine.Rendering
/// Volume Profile editor when you modify the Asset via script instead of the Inspector. /// Volume Profile editor when you modify the Asset via script instead of the Inspector.
/// </summary> /// </summary>
public void Reset() public void Reset()
{
isDirty = true;
}
=> dirtyState |= DirtyState.DirtyByProfileReset;
/// <summary> /// <summary>
/// Adds a <see cref="VolumeComponent"/> to this Volume Profile. /// Adds a <see cref="VolumeComponent"/> to this Volume Profile.
@ -100,7 +118,7 @@ namespace UnityEngine.Rendering
#endif #endif
component.SetAllOverridesTo(overrides); component.SetAllOverridesTo(overrides);
components.Add(component); components.Add(component);
isDirty = true;
dirtyState |= DirtyState.DirtyByComponentChange;
return component; return component;
} }
@ -142,7 +160,7 @@ namespace UnityEngine.Rendering
if (toRemove >= 0) if (toRemove >= 0)
{ {
components.RemoveAt(toRemove); components.RemoveAt(toRemove);
isDirty = true;
dirtyState |= DirtyState.DirtyByComponentChange;
} }
} }

2
Packages/com.unity.render-pipelines.core/package.json

@ -14,5 +14,5 @@
"com.unity.modules.jsonserialize": "1.0.0", "com.unity.modules.jsonserialize": "1.0.0",
"com.unity.rendering.light-transport": "1.0.1" "com.unity.rendering.light-transport": "1.0.1"
}, },
"_fingerprint": "bd0e8186c2bcfea109ee5981b813a1b39a6382fb"
"_fingerprint": "609b19816fd255e06290637a743a23085dbde6de"
} }

10
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."); Debug.LogWarning("Cannot instantiate AMD device because the version HDRP expects does not match the backend version.");
return false; 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 #else
return false; return false;
#endif #endif

37
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) #if defined(SUPPORT_WATER_DEFORMATION)
// Apply the deformation data // Apply the deformation data
float4 deformation = EvaluateWaterDeformation(positionAWS + verticalDisplacements);
float4 deformation = EvaluateWaterDeformation(positionAWS);
horizontalDisplacement = deformation.yz; horizontalDisplacement = deformation.yz;
verticalDisplacement += deformation.x; verticalDisplacement += deformation.x;
lowFrequencyHeight += deformation.x; lowFrequencyHeight += deformation.x;
@ -317,18 +317,20 @@ struct WaterDisplacementData
void EvaluateWaterDisplacement(float3 positionOS, out WaterDisplacementData displacementData) 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; 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; displacementData.lowFrequencyHeight = lowFrequencyHeight;
#if defined(SHADER_STAGE_VERTEX) && !defined(WATER_DISPLACEMENT) #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); ZERO_INITIALIZE(WaterAdditionalData, waterAdditionalData);
if (_GridSize.x < 0) if (_GridSize.x < 0)
return; 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); float distanceToCamera = length(positionRWS);
// Get the world space transformed postion // 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)); float2 decalUV = EvaluateDecalUV(transformedAWS - float3(horizontalDisplacement.x, 0.0f, horizontalDisplacement.y));
// Compute the texture size param for the filtering // Compute the texture size param for the filtering

2
Packages/com.unity.render-pipelines.high-definition/package.json

@ -100,5 +100,5 @@
] ]
} }
], ],
"_fingerprint": "28765669b6fee79d765751f370129f832b2c30c4"
"_fingerprint": "334d0e60f4bcdab1b4738903568de1a76a51824d"
} }

2
Packages/com.unity.shadergraph/package.json

@ -48,5 +48,5 @@
"path": "Samples~/CustomMaterialPropertyDrawers" "path": "Samples~/CustomMaterialPropertyDrawers"
} }
], ],
"_fingerprint": "f8b69e83dfddc9d7bbdcb1b4c60f079ffee88676"
"_fingerprint": "844e9247af8212b592252c83949e35127bce08e9"
} }

2
Packages/com.unity.ugui/Editor/UGUI/UI/ImageEditor.cs

@ -235,7 +235,7 @@ namespace UnityEditor.UI
if (EditorGUILayout.BeginFadeGroup(m_ShowTiled.faded)) 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)) 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(); EditorGUILayout.EndFadeGroup();

14
Packages/com.unity.ugui/Runtime/TMP/TMP_FontAssetUtilities.cs

@ -73,7 +73,7 @@ namespace TMPro
if (isItalic || fontWeight != FontWeight.Regular) 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; uint compositeUnicodeLookupKey = ((0x80u | ((uint)fontStyle << 4) | ((uint)fontWeight / 100)) << 24) | unicode;
if (sourceFontAsset.characterLookupTable.TryGetValue(compositeUnicodeLookupKey, out character)) if (sourceFontAsset.characterLookupTable.TryGetValue(compositeUnicodeLookupKey, out character))
{ {
@ -138,7 +138,7 @@ namespace TMPro
temp.characterLookupTable.Remove(unicode); 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)) if (temp.TryAddCharacterInternal(unicode, out character))
{ {
@ -150,7 +150,7 @@ namespace TMPro
} }
// Search potential fallbacks of the source font asset // 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 SearchFallbacksForCharacter(unicode, sourceFontAsset, fontStyle, fontWeight, out isAlternativeTypeface);
return null; return null;
@ -167,14 +167,14 @@ namespace TMPro
sourceFontAsset.characterLookupTable.Remove(unicode); 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)) if (sourceFontAsset.TryAddCharacterInternal(unicode, out character))
return 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 SearchFallbacksForCharacter(unicode, sourceFontAsset, fontStyle, fontWeight, out isAlternativeTypeface);
return null; return null;
@ -200,7 +200,7 @@ namespace TMPro
int id = temp.instanceID; 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) if (k_SearchedAssets.Add(id) == false)
continue; continue;

76
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. // Search for the character in potential local Sprite Asset assigned to the text object.
if (m_spriteAsset != null) if (m_spriteAsset != null)
{ {
@ -6182,44 +6220,6 @@ namespace TMPro
return spriteCharacter; 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; return null;
} }

14
Packages/com.unity.ugui/Runtime/UGUI/UI/Core/Graphic.cs

@ -839,7 +839,16 @@ namespace UnityEngine.UI
/// <param name="sp">Screen point being tested</param> /// <param name="sp">Screen point being tested</param>
/// <param name="eventCamera">Camera that is being used for the testing.</param> /// <param name="eventCamera">Camera that is being used for the testing.</param>
/// <returns>True if the provided point is a valid location for GraphicRaycaster raycasts.</returns> /// <returns>True if the provided point is a valid location for GraphicRaycaster raycasts.</returns>
public virtual bool Raycast(Vector2 sp, Camera eventCamera)
public virtual bool Raycast(Vector2 sp, Camera eventCamera) => Raycast(sp, eventCamera, false);
/// <summary>
/// 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.
/// </summary>
/// <param name="sp">Screen point being tested.</param>
/// <param name="eventCamera">Camera used for testing.</param>
/// <param name="ignoreMasks">If true, masks are ignored and do not prevent raycasts. </param>
/// <returns>True if the provided point is a valid location for GraphicRaycaster raycasts.</returns>
protected bool Raycast(Vector2 sp, Camera eventCamera, bool ignoreMasks)
{ {
if (!isActiveAndEnabled) if (!isActiveAndEnabled)
return false; return false;
@ -864,6 +873,9 @@ namespace UnityEngine.UI
if (filter == null) if (filter == null)
continue; continue;
if (ignoreMasks && components[i] is Mask or RectMask2D)
continue;
var raycastValid = true; var raycastValid = true;
var group = components[i] as CanvasGroup; var group = components[i] as CanvasGroup;

3
Packages/com.unity.ugui/Runtime/UGUI/UI/Core/MaskableGraphic.cs

@ -300,5 +300,8 @@ namespace UnityEngine.UI
m_ShouldRecalculateStencil = true; m_ShouldRecalculateStencil = true;
SetMaterialDirty(); SetMaterialDirty();
} }
/// <inheritdoc/>
public override bool Raycast(Vector2 sp, Camera eventCamera) => Raycast(sp, eventCamera, !maskable);
} }
} }

24
Packages/com.unity.ugui/Tests/Runtime/UGUI/Graphic/ImageTests.cs

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using NUnit.Framework; using NUnit.Framework;
using UnityEngine.EventSystems;
namespace UnityEngine.UI.Tests namespace UnityEngine.UI.Tests
{ {
@ -160,6 +161,29 @@ namespace UnityEngine.UI.Tests
Assert.IsTrue(raycast); 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<RectTransform>();
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] [Test]
public void SettingSpriteMarksAllAsDirty() public void SettingSpriteMarksAllAsDirty()
{ {

2
Packages/com.unity.ugui/package.json

@ -19,5 +19,5 @@
"com.unity.modules.ui": "1.0.0", "com.unity.modules.ui": "1.0.0",
"com.unity.modules.imgui": "1.0.0" "com.unity.modules.imgui": "1.0.0"
}, },
"_fingerprint": "423bc642aff1ba4fed4feef1d7b45461138cbb32"
"_fingerprint": "80da3b035d6b6df2ec3900d3eb384a0a4e79cffd"
} }

2
Packages/com.unity.visualeffectgraph/package.json

@ -36,5 +36,5 @@
] ]
} }
], ],
"_fingerprint": "c8dcb84572f2d0cfeef21465bb35296970fa0aa9"
"_fingerprint": "892d901f7a6641b3aa92b7920acf1d0fc38a0b95"
} }
Loading…
Cancel
Save