GUITexture tutorial?

Hi

I’m doing something similar to a fps and I need to draw a target (circle) at the center of the screen.

I was searching around and I believe I need to use a GUITexture for that. I tried playing with it but I can’t manage to get it centered or even preview it. Is there a GUITexture tutorial or anyone knows how to set it up so it’s centered at the screen?

What about text? Something like the number of lifes left. Is that GUIText or something else? Either way, I have no idea how to position it on the screen.

Regards

Check out: http://unity3d.com/support/documentation/Components/GUI%20Scripting%20Guide.html

But if you want something in the middle of the screen, when you define the x,y of the coords for the texture, use
x: screen.width / 2 - width of texture / 2
y: screen.height / 2 - height of texture / 2

Thanks wisemose. That was useful to learn the scripting :slight_smile:
I don’t see GUITexture in there though, is it a completely separate beast?

umm, check this out: http://unity3d.com/support/documentation/Components/class-GuiTexture.html
and this: http://unity3d.com/support/documentation/ScriptReference/GUITexture.html
Click through the second one, it will have code, generally this will go into a OnGUI method/function.
Most of the GUI methods/function work the same or very similarly.

Thanks again

Is there an alternative to GUITexture when displaying graphics? Searching the forum I found that GUITexture leaks memory when textures are not a power of 2.

Any alternatives and any advantages/disadvantages?

You could use the SpriteManager class(it’s really nice) to do a GUI:
http://forum.unity3d.com/viewtopic.php?t=17864

Look deep in the thread that Moses linked and you’ll find two different UI implementations ready-to-go built on the SpriteManager. Go with the one you feel more comfortable with.