keep getting error Array size must be at least width*height? how do you fix it Runtime error
public Texture2D[] atlasTextures;
public Rect[] rects;
public Texture2D atla;
void Start() {
Texture2D atlas = new Texture2D(8192, 8192);
rects = atlas.PackTextures(atlasTextures, 2, 8192);
atla = atlas;
StartCoroutine(Example());
}
IEnumerator Example() {
for(int i=0 ; i<atlasTextures.Length; i++){
int x = Mathf.FloorToInt(rects*.x);*
int y = Mathf.FloorToInt(rects*.x);*
int width = Mathf.FloorToInt(rects*.width);*
int height = Mathf.FloorToInt(rects*.height);*
Color[] pix = atla.GetPixels(x, y, width, height);
Texture2D destTex = new Texture2D(width, height,TextureFormat.ARGB32,false);
* destTex = atla;*
destTex.SetPixels(pix);
destTex.Apply();
renderer.material.mainTexture = destTex;
* yield return new WaitForSeconds(0.5f);*
* }*
}