Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by Henris088 · Sep 19, 2015 at 01:12 AM · maskclippingimageshealthbarhealth

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). alt text

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. alt text

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.

hunger.png (9.4 kB)
values.png (8.2 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

28 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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

Inputting another scripts variable as a float 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges