This repository has been archived by the owner on Sep 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
125 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using UnityEngine; | ||
|
||
|
||
namespace UniGLTF | ||
{ | ||
public class TextureExportManager | ||
{ | ||
List<Texture> m_textures; | ||
public List<Texture> Textures | ||
{ | ||
get { return m_textures; } | ||
} | ||
|
||
List<Texture> m_exportTextures; | ||
public Texture GetExportTexture(int index) | ||
{ | ||
if (index < 0 || index >= m_exportTextures.Count) | ||
{ | ||
return null; | ||
} | ||
if (m_exportTextures[index] != null) | ||
{ | ||
// コピー変換済み | ||
return m_exportTextures[index]; | ||
} | ||
|
||
// オリジナル | ||
return m_textures[index]; | ||
} | ||
|
||
public TextureExportManager(IEnumerable<Texture> textures) | ||
{ | ||
/* | ||
if (textures == null) | ||
{ | ||
throw new System.ArgumentNullException(); | ||
} | ||
*/ | ||
m_textures = textures.ToList(); | ||
m_exportTextures = new List<Texture>(Enumerable.Repeat<Texture>(null, m_textures.Count)); | ||
} | ||
|
||
public int CopyAndGetIndex(Texture texture, RenderTextureReadWrite readWrite) | ||
{ | ||
if (texture == null) | ||
{ | ||
return -1; | ||
} | ||
|
||
var index = m_textures.IndexOf(texture); | ||
if (index == -1) | ||
{ | ||
// ありえない? | ||
return -1; | ||
} | ||
|
||
// ToDo: may already exists | ||
m_exportTextures[index] = TextureItem.CopyTexture(texture, readWrite, null); | ||
|
||
return index; | ||
} | ||
|
||
public int ConvertAndGetIndex(Texture texture, ITextureConverter converter) | ||
{ | ||
if (texture == null) | ||
{ | ||
return -1; | ||
} | ||
|
||
var index = m_textures.IndexOf(texture); | ||
if (index == -1) | ||
{ | ||
// ありえない? | ||
return -1; | ||
} | ||
|
||
m_exportTextures[index] = converter.GetExportTexture(texture as Texture2D); | ||
|
||
return index; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters