Skip to content

Commit

Permalink
[Graphics Settings Strippers] Adding null checks to avoid exceptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-vazquez-unity3d authored and Evergreen committed Jul 1, 2024
1 parent 25d2b94 commit 206c513
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ internal static partial class RenderPipelineGraphicsSettingsStripper
{
private static bool CanRemoveSettings(this List<IStripper> strippers, [DisallowNull] Type settingsType, [DisallowNull] IRenderPipelineGraphicsSettings settings)
{
if (strippers == null)
return false;

const BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;

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

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

var settingsType = settings.GetType();

if (strippersMap.TryGetValue(settingsType, out var strippers))
if (strippersMap.TryGetValue(settingsType, out var strippers) && strippers != null)
{
if (!strippers.CanRemoveSettings(settingsType, settings))
isAvailableOnPlayerBuild = true;
Expand Down Expand Up @@ -80,7 +82,7 @@ public static void PerformStripping(
report.AddStrippedSetting(settings.GetType(), isAvailableOnPlayerBuild, strippersDefined);
}
}

}
}
}
Expand Down

0 comments on commit 206c513

Please sign in to comment.