Created
September 24, 2019 02:09
-
-
Save kaiware007/783ac270108dc301d36a0daa7e984c6c to your computer and use it in GitHub Desktop.
Create Texture2DArray
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
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