diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/NativeArrayManager.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/NativeArrayManager.cs index 7f51419b0..48902834c 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/NativeArrayManager.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/NativeArrayManager.cs @@ -2,6 +2,7 @@ using System; using System.Linq; using System.Collections.Generic; using Unity.Collections; +using System.Runtime.InteropServices; namespace UniGLTF { @@ -56,5 +57,24 @@ namespace UniGLTF array.CopyFrom(data); return array; } + + /// + /// サイズの違う型にコピーする。 + /// + /// 例 + /// NativeArray => NativeArray + /// + public NativeArray Convert(NativeArray src, Func convert) + where T : struct + where U : struct + { + var bytes = CreateNativeArray(src.Length * Marshal.SizeOf()); + var dst = bytes.Reinterpret(1); + for (int i = 0; i < src.Length; ++i) + { + dst[i] = convert(src[i]); + } + return dst; + } } }