Skip to content

Commit 206c513

Browse files
alex-vazquez-unity3dEvergreen
authored andcommitted
[Graphics Settings Strippers] Adding null checks to avoid exceptions.
Fixing null ref exception. https://jira.unity3d.com/browse/UUM-74223
1 parent 25d2b94 commit 206c513

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Packages/com.unity.render-pipelines.core/Runtime/Stripping/RenderPipelineGraphicsSettingsStripper.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ internal static partial class RenderPipelineGraphicsSettingsStripper
1010
{
1111
private static bool CanRemoveSettings(this List<IStripper> strippers, [DisallowNull] Type settingsType, [DisallowNull] IRenderPipelineGraphicsSettings settings)
1212
{
13+
if (strippers == null)
14+
return false;
15+
1316
const BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
1417

1518
var canRemoveSettings = true;
@@ -18,7 +21,7 @@ private static bool CanRemoveSettings(this List<IStripper> strippers, [DisallowN
1821

1922
foreach (var stripperInstance in strippers)
2023
{
21-
var methodInfo = stripperInstance.GetType().GetMethod($"{nameof(IRenderPipelineGraphicsSettingsStripper<IRenderPipelineGraphicsSettings>.CanRemoveSettings)}", flags);
24+
var methodInfo = stripperInstance?.GetType().GetMethod($"{nameof(IRenderPipelineGraphicsSettingsStripper<IRenderPipelineGraphicsSettings>.CanRemoveSettings)}", flags);
2225
if (methodInfo != null)
2326
canRemoveSettings &= (bool)methodInfo.Invoke(stripperInstance, methodArgs);
2427
}
@@ -36,8 +39,7 @@ private static bool CanTransferSettingsToPlayer(
3639
strippersDefined = false;
3740

3841
var settingsType = settings.GetType();
39-
40-
if (strippersMap.TryGetValue(settingsType, out var strippers))
42+
if (strippersMap.TryGetValue(settingsType, out var strippers) && strippers != null)
4143
{
4244
if (!strippers.CanRemoveSettings(settingsType, settings))
4345
isAvailableOnPlayerBuild = true;
@@ -80,7 +82,7 @@ public static void PerformStripping(
8082
report.AddStrippedSetting(settings.GetType(), isAvailableOnPlayerBuild, strippersDefined);
8183
}
8284
}
83-
85+
8486
}
8587
}
8688
}

0 commit comments

Comments
 (0)