diff --git a/Assets/UniGLTF/Runtime/UniGLTF/MaterialFacotry/MaterialFactory.cs b/Assets/UniGLTF/Runtime/UniGLTF/MaterialFacotry/MaterialFactory.cs
index 2ceb79a20..adcc9cc8a 100644
--- a/Assets/UniGLTF/Runtime/UniGLTF/MaterialFacotry/MaterialFactory.cs
+++ b/Assets/UniGLTF/Runtime/UniGLTF/MaterialFacotry/MaterialFactory.cs
@@ -58,8 +58,15 @@ namespace UniGLTF
return texture;
}
- texture = await LoadTextureAsync(param.Index0.Value);
- m_textureCache.Add(GetTextureParam.Create(param.Index0.Value), texture);
+ {
+ var defaultParam = GetTextureParam.Create(param.Index0.Value);
+ if (!m_textureCache.TryGetValue(defaultParam, out texture))
+ {
+ texture = await LoadTextureAsync(param.Index0.Value);
+ m_textureCache.Add(defaultParam, texture);
+ }
+ }
+
switch (param.TextureType)
{
case GetTextureParam.NORMAL_PROP:
diff --git a/Assets/UniGLTF/Runtime/UniGLTF/MaterialFacotry/MaterialItemBase.cs b/Assets/UniGLTF/Runtime/UniGLTF/MaterialFacotry/MaterialItemBase.cs
index 86e51d7e0..9d8538c8e 100644
--- a/Assets/UniGLTF/Runtime/UniGLTF/MaterialFacotry/MaterialItemBase.cs
+++ b/Assets/UniGLTF/Runtime/UniGLTF/MaterialFacotry/MaterialItemBase.cs
@@ -71,7 +71,12 @@ namespace UniGLTF
///
public static Material CreateMaterialForTest(int i, glTFMaterial material)
{
- throw new System.NotImplementedException();
+ var gltf = new glTF
+ {
+ materials = new System.Collections.Generic.List { material },
+ };
+ var task = DefaultCreateMaterialAsync(gltf, i, null);
+ return task.Result;
}
}
}
diff --git a/Assets/UniGLTF/Runtime/UniGLTF/MaterialFacotry/TextureLoader/GltfTextureLoader.cs b/Assets/UniGLTF/Runtime/UniGLTF/MaterialFacotry/TextureLoader/GltfTextureLoader.cs
index b557fb49c..cb91fe3e3 100644
--- a/Assets/UniGLTF/Runtime/UniGLTF/MaterialFacotry/TextureLoader/GltfTextureLoader.cs
+++ b/Assets/UniGLTF/Runtime/UniGLTF/MaterialFacotry/TextureLoader/GltfTextureLoader.cs
@@ -24,10 +24,10 @@ namespace UniGLTF
}
}
- public static async Task LoadTextureAsync(glTF gltf, IStorage storage, int index)
+ public static Task LoadTextureAsync(glTF gltf, IStorage storage, int index)
{
string m_textureName = default;
-
+
var imageIndex = gltf.GetImageIndexFromTextureIndex(index);
var segments = gltf.GetImageBytes(storage, imageIndex, out m_textureName);
var imageBytes = ToArray(segments);
@@ -50,7 +50,7 @@ namespace UniGLTF
{
TextureSamplerUtil.SetSampler(texture, sampler);
}
- return texture;
+ return Task.FromResult(texture);
}
}
}