Page 1 of 1

Make a vitals bar appear behind existing bars?

Posted: Mon Jul 16, 2018 3:01 am
by MeteoricDragon
I have some code that makes a verticalProgress bar appear in the same place as the health bar. I'd like to make it appear behind the health bar, but the health bar is verticalprogress : BaseScreenComponent : IDisposable, and is not inheriting from MonoBehavior, so It doesn't have an OnGUI method, so it can't benefit from GUI.depth like MonoBehavior objects can. Is there a way around this?

I want to see if I can program a damage indicator behind the health bar (non-directional, just an amount). So you lose health, the health bar goes down, and you see a red color bar where the health bar was, and then the red space shrinks to match the size of the health bar after a split second. Some games do something like this nowadays.

Re: Make a vitals bar appear behind existing bars?

Posted: Mon Jul 16, 2018 3:34 am
by MeteoricDragon
MeteoricDragon wrote: Mon Jul 16, 2018 3:01 am I have some code that makes a verticalProgress bar appear in the same place as the health bar. I'd like to make it appear behind the health bar, but the health bar is verticalprogress : BaseScreenComponent : IDisposable, and is not inheriting from MonoBehavior, so It doesn't have an OnGUI method, so it can't benefit from GUI.depth like MonoBehavior objects can. Is there a way around this?

I want to see if I can program a damage indicator behind the health bar (non-directional, just an amount). So you lose health, the health bar goes down, and you see a red color bar where the health bar was, and then the red space shrinks to match the size of the health bar after a split second. Some games do something like this nowadays.
It looks like if i add the component to the parent in a different order, the red bar appears behind the health bar.

Re: Make a vitals bar appear behind existing bars?

Posted: Wed Jul 18, 2018 12:15 am
by Interkarma
Glad you found the solution. I see what you're getting at, and will test code in a branch shortly. :)