Search Unity

Z index?

Discussion in 'Immediate Mode GUI (IMGUI)' started by hatman, May 5, 2009.

  1. hatman

    hatman

    Joined:
    Feb 3, 2009
    Posts:
    333
    Im using this to set the GUI texture:

    GUI.DrawTexture (Rect (0,0, withTimer.width, withTimer.height), withTimer);


    How can I set the z index of it (as I have text that goes over the top)

    Cheers
     
  2. hatman

    hatman

    Joined:
    Feb 3, 2009
    Posts:
    333
    Ive tried

    myGUI.Transform.position.z=-10;

    but it doesnt work... please help
     
  3. DocSWAB

    DocSWAB

    Joined:
    Aug 28, 2006
    Posts:
    615
    The GUI class does not have a transform and does not occupy space in the 3D game space.

    All GUI calls are always rendered in front of everything else in the main game world.

    As far as drawing order of GUI elements, for a given OnGUI function execution, the layering will depend on the order you have them drawing in your code.

    If you are trying to control the order of GUI elements being drawn by different scripts, use this:
    http://unity3d.com/support/documentation/ScriptReference/GUI-depth.html

    Also, if you are just trying to use a texture for a window or button background, you probably want to define custom GUI styles using the image instead of drawing it separately. And the system will do a lot more for you.