Merge pull request #557 from ousttrue/fix/renderer_materials_null

fix null in Renderer.sharedMaterials
This commit is contained in:
ousttrue 2020-09-15 15:18:41 +09:00 committed by GitHub
commit a2ffc3cffc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -328,9 +328,23 @@ namespace VRM
}
var renderers = ExportRoot.GetComponentsInChildren<Renderer>();
var materials = renderers.SelectMany(x => x.sharedMaterials).Distinct();
foreach (var r in renderers)
{
for(int i=0; i<r.sharedMaterials.Length; ++i)
if (r.sharedMaterials[i] == null)
{
yield return Validation.Error($"Renderer: {r.name}.Materials[{i}] is null. please fix it");
}
}
var materials = renderers.SelectMany(x => x.sharedMaterials).Where(x => x != null).Distinct();
foreach (var material in materials)
{
if (material == null)
{
continue;
}
if (material.shader.name == "Standard")
{
// standard