- Home /
Ordering of new UI and legacy UI
Hello!
I am currently working on a new RTS game. My game features a canvas at the bottom of the screen for displaying information about a castle (it's kind of like a castle attack/defend type game). This is being done with the newer UI system provided by unity. But, I am also using the OnGUI method to draw legacy UI elements. I am using the legacy UI because it seemed more ideal for other things I wanted to do - such as enemy healthbars.
My issue is this: I want some of the legacy UI to appear below the canvas (enemy healthbars), because it looks silly having healthbars overlap the main UI of the game. But, I also want other parts of the legacy UI to appear above the main UI, because I'm using it to display little tooltips for buttons.
I tried adding two cameras to my game, one for drawing UI, and one for everything else. This worked for hiding the healthbars behind the main canvas, but it also hit the little tooltips which is something i didn't want to happen.
Is there an easier way to order specific OnGUI elements and canvas elements? I tried using raycasting to detect whether any of the enemy gameobjects were behind the canvas, but then I learnt that raycasting doesn't work for UI. I have heard graphics raycasting is for UI, but then that may not support gameobject screen positions I'm guessing. If only I could easily detect whether a gameobject is hidden BEHIND a canvas element, then I can simply add an if statement in the OnGUI code to stop it drawing it.
Thanks!
Your answer
Follow this Question
Related Questions
Camera only showing 'touching' objects 2 Answers
How do i Instantiate sub-Points with in Multiple Points?? 1 Answer
Problem with curved Cornered Spline that i need help with 0 Answers
If I have a button over my 3d world, how can I detect if a mouseClick was in the world or not? 5 Answers
Can't see textures 0 Answers