UniVRM/Assets/VRM10/Runtime/IO/ModelExtensions.cs
ousttrue e35bc5f2fe GetBytesWithMime を VRMShaders に移動
* UniGLTF.GltfTextureExporter.GetBytesWithMime を VRMShaders.AssetTextureUtil.GetTextureBytesWithMime に移動
* テスト NotReadable, Compressed を VRMShaders に移動
* テスト用リソース Resources/4x4.png と 4x4compressed.DDS を VRMShaders に移動
2021-04-12 18:17:24 +09:00

23 lines
622 B
C#

using System;
using UnityEngine;
namespace UniVRM10
{
public static class ModelExtensions
{
public static byte[] ToGlb(this VrmLib.Model model, Func<Texture2D, (byte[], string)> getTextureBytes)
{
// export vrm-1.0
var exporter10 = new Vrm10Exporter(_ => false);
var option = new VrmLib.ExportArgs
{
// vrm = false
};
exporter10.Export(null, model, null, option, getTextureBytes);
var glb10 = UniGLTF.Glb.Parse(exporter10.Storage.ToBytes());
return glb10.ToBytes();
}
}
}