Merge pull request #409 from hiroj/fix_argument_textureitem

Fix argument textureitem
This commit is contained in:
hiroj
2020-05-22 16:08:45 +09:00
committed by GitHub
3 changed files with 18 additions and 20 deletions

View File

@@ -394,7 +394,16 @@ namespace UniGLTF
Root.name = Path.GetFileNameWithoutExtension(path);
}
public virtual void CreateTextureItems(UnityPath imageBaseDir = default(UnityPath))
public virtual ITextureLoader CreateTextureLoader(int index)
{
#if UNIGLTF_USE_WEBREQUEST_TEXTURELOADER
return new UnityWebRequestTextureLoader(index);
#else
return new TextureLoader(index);
#endif
}
public void CreateTextureItems(UnityPath imageBaseDir = default(UnityPath))
{
if (m_textures.Any())
{
@@ -422,7 +431,7 @@ namespace UniGLTF
else
#endif
{
item = new TextureItem(i);
item = new TextureItem(i, CreateTextureLoader(i));
}
AddTexture(item);

View File

@@ -110,26 +110,15 @@ namespace UniGLTF
/// Texture from buffer
/// </summary>
/// <param name="index"></param>
public TextureItem(int index, ITextureLoader textureLoader = null)
public TextureItem(int index, ITextureLoader textureLoader)
{
m_textureIndex = index;
if(textureLoader == null)
{
m_textureLoader = CreateTextureLoader(index);
}
else
{
m_textureLoader = textureLoader;
}
}
m_textureLoader = textureLoader;
private static ITextureLoader CreateTextureLoader(int index)
{
#if UNIGLTF_USE_WEBREQUEST_TEXTURELOADER
return new UnityWebRequestTextureLoader(index);
#else
return new TextureLoader(index);
#endif
if(m_textureLoader == null)
{
throw new Exception("ITextureLoader is null.");
}
}
#if UNITY_EDITOR

View File

@@ -307,7 +307,7 @@ namespace VRM
// 作成する(先行ロード用)
if (gltfMeta.texture >= 0 && gltfMeta.texture < GLTF.textures.Count)
{
var t = new TextureItem(gltfMeta.texture);
var t = new TextureItem(gltfMeta.texture, CreateTextureLoader(gltfMeta.texture));
t.Process(GLTF, Storage);
meta.Thumbnail = t.Texture;
}