Make a vitals bar appear behind existing bars?

Discuss coding questions, pull requests, and implementation details.
Post Reply
User avatar
MeteoricDragon
Posts: 88
Joined: Mon Feb 12, 2018 8:23 pm

Make a vitals bar appear behind existing bars?

Post by MeteoricDragon » 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.

User avatar
MeteoricDragon
Posts: 88
Joined: Mon Feb 12, 2018 8:23 pm

Re: Make a vitals bar appear behind existing bars?

Post by MeteoricDragon » Mon Jul 16, 2018 3:34 am

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.

User avatar
Interkarma
Posts: 3030
Joined: Sun Mar 22, 2015 1:51 am

Re: Make a vitals bar appear behind existing bars?

Post by Interkarma » Wed Jul 18, 2018 12:15 am

Glad you found the solution. I see what you're getting at, and will test code in a branch shortly. :)

Post Reply