I have recently begun using the new UI system and are quite liking it, but i have one major issue that i cannot seem to fix.
I have a texture that needs to fill the screen with a dynamic width/height and that has always worked pixel perfect using the GUI.DrawTexture method in the OnGUI pass, but this does not seem to work in tandem with the new UI system.
Rendering the texture using RawTexture on the UI makes the same effect and it will scale accordingly, but dynamically adjusting the texture gives me very slight black bars in the top and right sides of the screen. I would prefer to use the GUI.DrawTexture method and then draw the UI on top of that, but i cannot seem to get the new UI to render at a higher depth than the GUI.DrawTexture call.
In short, how do i draw new Unity UI elements on top of a GUI.DrawTexture call?
I have not been able to get it to be pixel perfect using the new GUI, the image always seems to have missing pixels in the sides when the image is scaled to a resolution that is not equal by multiplying by two, the image is just not streched to the boundaries of the canvas.
No, that wouldn’t fix it as it would scale the image to its 1:1 ratio, something i wouldn’t need to do unless the image has a 100% similar pixel size compared to the canvas.
I did however fix the problem. The new UI is not happy when you serve it images that aren’t an equal number on either side, so an image that is 91 pixels wide would not be able to fill the RawTexture element completely and therefore give me black borders. The fix is to check if both the width and height of the texture is an equal number, if not it should be fixed before doing the scale.