Question by
captaintechnicality · Apr 29, 2018 at 04:55 PM ·
graphicstexture2dtextures
SetPixels Non-Deterministic Results
I'm trying to put some textures onto a texture sheet dynamically. I'm not using pack textures because I'm not using a perfect cube and I need it to match my UVs. Instead, I'm using GetPixels and SetPixels like this:
Texture2D tex = new Texture2D(512, 512, TextureFormat.RGBA32, false);
for(int i = 0; i < 6; i++)
{
tex.SetPixels(offsets[i].x * 128, offsets[i].y * 128, 128, 128, textures[i].GetPixels());
}
GetComponent<MeshRenderer>().material.SetTexture("_MainTex", tex);
displayImage.texture = tex;
When using this method however, it finishes a non-deterministic number of faces, usually between 0-4 before it finishes. In debugging the code, it does go through the loop all 6 times.
Does anyone know why this happens? PackTextures doesn't do quite what I want.
unity-2018-04-29-09-44-02.png
(134.7 kB)
unity-2018-04-29-09-46-47.png
(144.2 kB)
Comment