Search Unity

Minimap always on top

Discussion in 'Immediate Mode GUI (IMGUI)' started by Excidias, Jul 31, 2014.

  1. Excidias

    Excidias

    Joined:
    Jul 31, 2014
    Posts:
    7
    Hi everyone,
    I am relatively new at unity with roughly 2 months under my belt. I am quite happy with how my game is progressing but I have ran into an issue. I have created a minimap and the textures of my GUI are always drawn on top. I have googled extensively and have not found any real way to solve this dilemma. If you guys have any guidance, I would greatly appreciate it. Thank you for the help!

    Here is a screenshot of the issue.

    minimap health bar.png
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    If you're using OnGUI code, the only real way to avoid that is to use rendertextures and make the map drawn with OnGUI as well, which requires Pro. Without Pro (or even with it), you can avoid the entire issue by using GUIText/GUITexture objects instead.

    --Eric
     
  3. Excidias

    Excidias

    Joined:
    Jul 31, 2014
    Posts:
    7
    Thank you for the quick reply Chris. I attempted to rectify this issue with using a map which rendered into a texture. I then used DrawTexture to display it and I am drawing the minimap last in relation to the health bar but it still appears to be an issue. Are there any special settings I am suppose to change to fix this? Again, thank you for you help. I very much appreciate it.
    minimap health bar 2.png
     
  4. Zaflis

    Zaflis

    Joined:
    May 26, 2014
    Posts:
    438
    In the OnGUI event, call the healthbar drawing line first and then minimap. That is solution to the drawing order. There are also other ways to make that kind of healthbars than OnGUI. You can look into Mesh Renderer and Text Mesh.
     
  5. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Chris? :confused: ;) Look into GUI.depth (requires separate OnGUI functions).

    --Eric
     
  6. Excidias

    Excidias

    Joined:
    Jul 31, 2014
    Posts:
    7
    Haha, my fault Eric. My friend Chris was skyping with me at the time and I must have had a brain skip. Zaflis, I am drawing them in that order. I'll check out GUI.depth after I'm done teaching today. Thank you for your help Zaflis and Eric*!
     
  7. Excidias

    Excidias

    Joined:
    Jul 31, 2014
    Posts:
    7
    I wanted to come back and explain that this has been fixed by changing the GUI.depth from opposite classes. For anyone else running into this issue, the lower number depth is drawn last and not first. Thanks Eric!