Skip to content

Instantly share code, notes, and snippets.

@kaiware007
Created September 24, 2019 02:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaiware007/783ac270108dc301d36a0daa7e984c6c to your computer and use it in GitHub Desktop.
Save kaiware007/783ac270108dc301d36a0daa7e984c6c to your computer and use it in GitHub Desktop.
Create Texture2DArray
public class Texture2DArrayCreator {
[SerializeField]
Texture2D[] textures;
public Texture2DArray texArray = null;
void CreateTexture2DArray()
{
int width = textures[0].width;
int height = textures[0].height;
int depth = textures.Length;
TextureFormat format = textures[0].format;
texArray = new Texture2DArray(width, height, depth, format, false);
texArray.filterMode = FilterMode.Bilinear;
texArray.wrapMode = TextureWrapMode.Repeat;
for (int i = 0; i < depth; i++)
{
texArray.SetPixels(textures[i].GetPixels(), i);
}
texArray.Apply();
}
void Start(){
CreateTexture2DArray();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment