GUI Texture slide down || Clipping mask.
Hello guys. So here`s my script to make it all clear before explaining:
//Hunger
GUI.BeginGroup(new Rect(Screen.width - ((hungerTexture.width + 10) * 2), Screen.height - hungerTexture.height - 10, hungerTexture.width, hungerTexture.height));
GUI.DrawTexture(Rect(0,0, hungerTexture.width, hungerTexture.height), hungerEmpty);
GUI.BeginGroup(new Rect(0,0 + (hungerTexture.height - (hungerTexture.height * _PlayerStats.Hunger)), hungerTexture.width, hungerTexture.height * _PlayerStats.Hunger));
GUI.DrawTexture(Rect(0,0, hungerTexture.width, hungerTexture.height), hungerTexture);
GUI.EndGroup();
GUI.EndGroup();
So this creates a texture empty hunger. On top it creates full hunger texture. Full hunger texture is multiplied by Hunger value (which is max 1) so it represents the hunger by sizing texture`s height down according to Hunger value.
Works perfectly. Problem is - while it scaling down the empty spaces comes from the bottom. I`ll paint a picture to explain. (Please see below).
So I thought if I make the second ( Full texture ) go lower depending of the value of Hunger it should work and it did HOORAY!
(hungerTexture.height - (hungerTexture.height * _PlayerStats.Hunger))
Sadly, it does work perfectly with bars, but while using more complex texture, for example lets say Circle to make it simple it wont work, you can probably guess what happens, it just moves whole texture down and it does not look as it should. Added a picture to make it clearer.
Its obvious why it happens, but I can`t figure out how to do it the way I want it. I thought of making a .gif image or just a group of images and displaying certain image depending on the value of Hunger. But that would take to much time and would not look that good anyway there should be an easier way.
It would be nice if you could somehow implement clipping mask as in Photoshop. :)
If you had any experience or know a way how to make it work, please answer! I would really appreciate it. Thank you for taking your time reading this. :)
*EDIT : My code keeps changing to something like: %|-1597563204_4|% so if you see this please reply I`ll add a picture of code, but I think it works good now, just in case.
Your answer
Follow this Question
Related Questions
Healthbar system not working correctly 0 Answers
How to create a link between HealthScript and HealtBar script ? 1 Answer
Help with a health bar 0 Answers
Clip 3D Object to specific volume 2 Answers