I have a texture that is 256x64. I need to render from 0,0 to 63,63 in this texture (A 64x64 sub-rect). How can I do this using GUI.Box()?
I've tried specifying a GUIStyle that sets contentOffset to (0,0) and fixedWidth/fixedHeight to 64,64 but this didn't work.
asked Mar 03 '10 at 11:03 PM
Take a look at Graphics.DrawTexture.
You can specify a material and, with so, UV coordinates. This way you can draw only a portion of your texture inside OnGUI calls. You must end up with something like it:
is your sourceRect (texture portion that you want to draw).
answered Mar 22 '10 at 02:36 PM
I think you can use GUI.DrawTexture, e.g. (C#):
There are several ways, copy only that part of the texture to a new texture using GetPixels (or something like that I dont remember pretty well now).
another one is render to texture from another camera only that part of the texture (which I think is kinda hacky)
I would use the 1rst one I suggested you.
answered Mar 22 '10 at 02:13 PM
Naruse was correct, although I will flesh out his answer a bit:
Use Texture2D.GetPixels to get the area of pixels you want. Then, create a new Texture2D object, and call Texture2D.SetPixels to write the extracted section of pixels to the new texture object. Then, call
answered May 31 '10 at 09:31 PM