c# - Load array of textures into individual Image components into a grid layout in Unity 4.6 (using uGUI) -
i'm having lot of trouble trying develop loader grabs group of textures located in array , populates them grid layout. share code insight or snippet might trick?
lets want show images in format below. can merging images 1 big texture2d (but know image size should not exceed 2048x2048)
the function below should work:
private texture2d concattexture(texture2d[,] textures, int imagewidth, int imageheight) { int rowcount = textures.getlength(0); int columncount = textures.getlength(1); //space allocation final texture texture2d finaltexture = new texture2d(columncount * imagewidth, rowcount * imageheight); (int = 0; < rowcount; i++) for(int j=0 ; j < columncount ; j++) finaltexture.setpixels(j * imagewidth, (rowcount-i-1) * imageheight, imagewidth, imageheight, textures[i, j].getpixels()); return finaltexture; }
you can edit code , put spaces between images if looking for.
Comments
Post a Comment