From 8e5479772d9d5fe4aef2dc07dc8e36239b39b32e Mon Sep 17 00:00:00 2001 From: ousttrue Date: Mon, 27 Dec 2021 19:39:30 +0900 Subject: [PATCH] =?UTF-8?q?HasVertexColor=20=E3=81=A7=E4=B8=AD=E8=BA=AB?= =?UTF-8?q?=E3=82=92=E8=A6=8B=E3=81=A6=E5=88=A4=E6=96=AD=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/UniGLTF/Runtime/UniGLTF/IO/GltfData.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/GltfData.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/GltfData.cs index 9ae339707..2a6227ad4 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/GltfData.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/GltfData.cs @@ -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(attributes.COLOR_0); + foreach (var color in colors) + { + if (color != ZERO) + { + return true; + } + } + // すべて (0, 0, 0, 0) だった。使っていないと見做す。 + return false; } public bool MaterialHasVertexColor(int materialIndex)