diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/ExtensionSupportFlags.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/ExtensionSupportFlags.cs
index e84684e5f..0ae47adb9 100644
--- a/Assets/UniGLTF/Runtime/UniGLTF/IO/ExtensionSupportFlags.cs
+++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/ExtensionSupportFlags.cs
@@ -5,7 +5,7 @@
///
/// KHR_texture_basisu 拡張を考慮するかどうか。
///
- public bool ConsiderKhrTextureBasisu { get; set; }
+ public bool ConsiderKhrTextureBasisu { get; set; } = true;
///
/// ファイルに含まれる "全ての" テクスチャの画像が Y 軸反転しているかどうか。
diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/ImporterContext.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/ImporterContext.cs
index cabc59f83..e05d60b09 100644
--- a/Assets/UniGLTF/Runtime/UniGLTF/IO/ImporterContext.cs
+++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/ImporterContext.cs
@@ -36,7 +36,6 @@ namespace UniGLTF
ITextureDeserializer textureDeserializer = null,
IMaterialDescriptorGenerator materialGenerator = null)
{
- TryValidateGltfData(data);
Data = data;
TextureDescriptorGenerator = new GltfTextureDescriptorGenerator(Data);
MaterialDescriptorGenerator = materialGenerator ?? MaterialDescriptorGeneratorUtility.GetValidGltfMaterialDescriptorGenerator();
@@ -75,21 +74,6 @@ namespace UniGLTF
"KHR_draco_mesh_compression",
};
- ///
- /// GltfData をバリデートし、読み込み不可能な問題があれば例外を投げる
- ///
- private static void TryValidateGltfData(GltfData data)
- {
- if (data.ExtensionSupportFlags.ConsiderKhrTextureBasisu && !Application.isPlaying)
- {
- throw new UniGLTFNotSupportedException("KHR_texture_basisu is only available in play mode.");
- }
- if (data.ExtensionSupportFlags.ConsiderKhrTextureBasisu && !data.ExtensionSupportFlags.IsAllTexturesYFlipped)
- {
- throw new UniGLTFNotSupportedException("KHR_texture_basisu is only supported with all textures Y-flipped.");
- }
- }
-
#region Load. Build unity objects
public virtual async Task LoadAsync(IAwaitCaller awaitCaller, Func MeasureTime = null)
{
diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/GltfTextureImporter.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/GltfTextureImporter.cs
index f373dbe01..b5c56298f 100644
--- a/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/GltfTextureImporter.cs
+++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/GltfTextureImporter.cs
@@ -238,13 +238,16 @@ namespace UniGLTF
{
var texture = data.GLTF.textures[textureIndex];
- if (data.ExtensionSupportFlags.ConsiderKhrTextureBasisu &&
- glTF_KHR_texture_basisu.TryGet(texture, out var basisuExtension))
+ if (glTF_KHR_texture_basisu.TryGet(texture, out var basisuExtension))
{
- var basisuImageIndex = basisuExtension.source;
- if (basisuImageIndex >= 0 && basisuImageIndex < data.GLTF.images.Count)
+ // NOTE: 実際に basisu 拡張が存在するとき、ロード設定を確認する。
+ if (TryValidateBasisuLoadingSettings(data))
{
- return basisuImageIndex;
+ var basisuImageIndex = basisuExtension.source;
+ if (basisuImageIndex >= 0 && basisuImageIndex < data.GLTF.images.Count)
+ {
+ return basisuImageIndex;
+ }
}
}
@@ -257,6 +260,22 @@ namespace UniGLTF
return default;
}
+
+ private static bool TryValidateBasisuLoadingSettings(GltfData data)
+ {
+ if (!data.ExtensionSupportFlags.ConsiderKhrTextureBasisu) return false;
+
+ if (data.ExtensionSupportFlags.ConsiderKhrTextureBasisu && !Application.isPlaying)
+ {
+ throw new UniGLTFNotSupportedException("KHR_texture_basisu is only available in play mode.");
+ }
+ if (data.ExtensionSupportFlags.ConsiderKhrTextureBasisu && !data.ExtensionSupportFlags.IsAllTexturesYFlipped)
+ {
+ throw new UniGLTFNotSupportedException("KHR_texture_basisu is only supported with all textures Y-flipped.");
+ }
+ return true;
+ }
+
private static byte[] ToArray(NativeArray bytes)
{