Skip to content

Commit

Permalink
Merge pull request #408 from hiroj/fix_createTextureItem
Browse files Browse the repository at this point in the history
Changed to be able to extend texture loader.
  • Loading branch information
ousttrue authored May 22, 2020
2 parents 582461e + c7eefa5 commit dde0f1d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Assets/VRM/UniGLTF/Scripts/IO/ImporterContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ public void Load(string path, byte[] bytes)
Root.name = Path.GetFileNameWithoutExtension(path);
}

public void CreateTextureItems(UnityPath imageBaseDir = default(UnityPath))
public virtual void CreateTextureItems(UnityPath imageBaseDir = default(UnityPath))
{
if (m_textures.Any())
{
Expand Down
18 changes: 15 additions & 3 deletions Assets/VRM/UniGLTF/Scripts/IO/TextureItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,25 @@ public IEnumerable<Texture2D> GetTexturesForSaveAssets()
/// Texture from buffer
/// </summary>
/// <param name="index"></param>
public TextureItem(int index)
public TextureItem(int index, ITextureLoader textureLoader = null)
{
m_textureIndex = index;
if(textureLoader == null)
{
m_textureLoader = CreateTextureLoader(index);
}
else
{
m_textureLoader = textureLoader;
}
}

private static ITextureLoader CreateTextureLoader(int index)
{
#if UNIGLTF_USE_WEBREQUEST_TEXTURELOADER
m_textureLoader = new UnityWebRequestTextureLoader(m_textureIndex);
return new UnityWebRequestTextureLoader(index);
#else
m_textureLoader = new TextureLoader(m_textureIndex);
return new TextureLoader(index);
#endif
}

Expand Down

0 comments on commit dde0f1d

Please sign in to comment.