Skip to content

Commit 59acce2

Browse files
committed
missing null check
1 parent 9759f7b commit 59acce2

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

Assets/Scripts/Core/GoWrapper.cs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,11 @@ virtual protected void ApplyClipping(UpdateContext context)
297297
int cnt = _renderers.Count;
298298
for (int i = 0; i < cnt; i++)
299299
{
300-
_renderers[i].renderer.GetMaterials(helperMaterials);
300+
Renderer renderer = _renderers[i].renderer;
301+
if (renderer == null)
302+
continue;
303+
304+
renderer.GetMaterials(helperMaterials);
301305

302306
int cnt2 = helperMaterials.Count;
303307
for (int j = 0; j < cnt2; j++)
@@ -313,17 +317,16 @@ virtual protected void ApplyClipping(UpdateContext context)
313317
int cnt = _renderers.Count;
314318
for (int i = 0; i < cnt; i++)
315319
{
316-
RendererInfo ri = _renderers[i];
317-
Material[] mats = ri.materials;
318-
if (mats != null)
320+
Material[] mats = _renderers[i].materials;
321+
if (mats == null)
322+
continue;
323+
324+
int cnt2 = mats.Length;
325+
for (int j = 0; j < cnt2; j++)
319326
{
320-
int cnt2 = mats.Length;
321-
for (int j = 0; j < cnt2; j++)
322-
{
323-
Material mat = mats[j];
324-
if (mat != null)
325-
context.ApplyClippingProperties(mat, false);
326-
}
327+
Material mat = mats[j];
328+
if (mat != null)
329+
context.ApplyClippingProperties(mat, false);
327330
}
328331
}
329332
#endif

0 commit comments

Comments
 (0)