Skip to content

Commit e79621e

Browse files
committed
Added nullcheck for modules in modular shaders
1 parent 2533102 commit e79621e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Editor/ShaderGenerator.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -817,8 +817,8 @@ public static List<ShaderModule> FindAllModules(ModularShader shader)
817817
{
818818
List<ShaderModule> modules = new List<ShaderModule>();
819819
if (shader == null) return modules;
820-
modules.AddRange(shader.BaseModules);
821-
modules.AddRange(shader.AdditionalModules);
820+
modules.AddRange(shader.BaseModules.Where(x => x != null));
821+
modules.AddRange(shader.AdditionalModules.Where(x => x != null));
822822
return modules;
823823
}
824824

@@ -881,6 +881,7 @@ public static List<ShaderModule> FindActiveModules(ModularShader shader, Diction
881881

882882
foreach (var module in shader.BaseModules)
883883
{
884+
if (module == null) continue;
884885
bool hasEnabler = module.EnableProperties.Any(x => x != null && !string.IsNullOrEmpty(x.Name));
885886
bool hasKey = hasEnabler && module.EnableProperties.Any(x => activeEnablers.TryGetValue(x.Name, out _));
886887
if (!hasEnabler || !hasKey || (module.EnableProperties.All(x =>
@@ -894,6 +895,7 @@ public static List<ShaderModule> FindActiveModules(ModularShader shader, Diction
894895

895896
foreach (var module in shader.AdditionalModules)
896897
{
898+
if (module == null) continue;
897899
bool hasEnabler = module.EnableProperties.Any(x => x != null && !string.IsNullOrEmpty(x.Name));
898900
bool hasKey = hasEnabler && module.EnableProperties.Any(x => activeEnablers.TryGetValue(x.Name, out _));
899901
if (!hasEnabler || !hasKey || (module.EnableProperties.All(x =>

0 commit comments

Comments
 (0)