HasVertexColor で中身を見て判断する

This commit is contained in:
ousttrue 2021-12-27 19:39:30 +09:00
parent 38a3c76116
commit 8e5479772d

View File

@ -330,9 +330,26 @@ namespace UniGLTF
}
}
// not black(0, 0, 0, 1)
static readonly UnityEngine.Color ZERO = new UnityEngine.Color(0, 0, 0, 0);
public bool HasVertexColor(glTFAttributes attributes)
{
return attributes.COLOR_0 != -1;
if (attributes.COLOR_0 == -1)
{
return false;
}
var colors = GetArrayFromAccessor<UnityEngine.Color>(attributes.COLOR_0);
foreach (var color in colors)
{
if (color != ZERO)
{
return true;
}
}
// すべて (0, 0, 0, 0) だった。使っていないと見做す。
return false;
}
public bool MaterialHasVertexColor(int materialIndex)