diff --git a/Assets/UniGLTF/Runtime/Extensions/glTFExtensions.cs b/Assets/UniGLTF/Runtime/Extensions/glTFExtensions.cs index 2ea4400cd..5ef920f63 100644 --- a/Assets/UniGLTF/Runtime/Extensions/glTFExtensions.cs +++ b/Assets/UniGLTF/Runtime/Extensions/glTFExtensions.cs @@ -72,6 +72,10 @@ namespace UniGLTF { return cv.ComponentType; } + else if (typeof(T) == typeof(ushort)) + { + return glComponentType.UNSIGNED_SHORT; + } else if (typeof(T) == typeof(uint)) { return glComponentType.UNSIGNED_INT; @@ -119,10 +123,10 @@ namespace UniGLTF } } - public static int ExtendBufferAndGetAccessorIndex(this glTF gltf, int bufferIndex, T[] array, + public static int ExtendBufferAndGetAccessorIndex(this glTF gltf, int bufferIndex, IReadOnlyList list, glBufferTarget target = glBufferTarget.NONE) where T : struct { - return gltf.ExtendBufferAndGetAccessorIndex(bufferIndex, new ArraySegment(array), target); + return gltf.ExtendBufferAndGetAccessorIndex(bufferIndex, new ArraySegment(list.ToArray()), target); } public static int ExtendBufferAndGetAccessorIndex(this glTF gltf, int bufferIndex, diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshExporter_SharedVertexBuffer.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshExporter_SharedVertexBuffer.cs index 192077151..1c4be08d9 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshExporter_SharedVertexBuffer.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshExporter_SharedVertexBuffer.cs @@ -127,7 +127,7 @@ namespace UniGLTF indices.Add((uint)i0); } - var indicesAccessorIndex = gltf.ExtendBufferAndGetAccessorIndex(bufferIndex, indices.ToArray(), glBufferTarget.ELEMENT_ARRAY_BUFFER); + var indicesAccessorIndex = gltf.ExtendBufferAndGetAccessorIndex(bufferIndex, indices, glBufferTarget.ELEMENT_ARRAY_BUFFER); if (indicesAccessorIndex < 0) { // https://github.com/vrm-c/UniVRM/issues/664