GUI Texture vs Texture2D: which one

Hi all,

can someone explain me the difference between GUI Texture and Texture2D?

I need to have an image in the middle of the screen, so until now I’ve created a flat plane with an attached material, but i was thinking that a flat 2D GUI image would be better, what u think?

I was reading this, but it says “Please Note: Unity 2.0 introduced UnityGUI, a GUI Scripting system. You may prefer creating user interface elements with UnityGUI instead of GUI Textures. Read more about how to use UnityGUI in the GUI Scripting Guide”

I’ve also noticed that while the 3d flat plane adjusts itself if I resize the screen, a GUI Texture created in the editor hasn’t the same behavior, so I’m thinking that the best way is to add a Texture2D image by script, and positioning/sizing it looking for the current Screen dimension.

so something like this:

GUI.Label (new Rect (Screen.width/2-100,0,200,50), myTexture2D);

Do you think i’m doing the right way?

Thanks so much!!

The OnGUI system is pretty slow on performance and is about to be replaced again sometime in 4.x (thank goodness).

A plane placed in front of a camera with the texture on it gives you good performance and the most flexibility. Using multiple cameras really helps. Often you would want your GUI camera to be orthographic too.

OnGUI can be scaled quite easily using GUI.matrix - which is one advantage.

Packages like NGUI use multiple cameras (orthographic) and contain tools to do the stretching etc for you - plus they atlas all of your graphics and fonts to make performance higher.