Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

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.