• 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 /
avatar image
Question by MateusLog · Mar 21, 2015 at 06:45 PM · progress-bardecreaseminuteshealth barhealth

progress bar

I would like to make it descends from the top down but he's only decendo to right to left someone help me?

 #pragma strict
 
 var tamanhovida : Vector2 = new Vector2(10, 40);
 var tamanhofome : Vector2 = new Vector2(10, 40);
 var tamanhosede : Vector2 = new Vector2(10, 40);
 
 var skin : GUISkin;
 
 var vida : Vector2 = new Vector2(20, 20);
 var barravida : float = 1;
 var vidacheia : Texture2D;
 var vidavazia : Texture2D;
 
 var fome : Vector2 = new Vector2(20, 60);
 var barrafome : float = 1;
 var fomecheia : Texture2D;
 var fomevazia : Texture2D;
 
 var sede : Vector2 = new Vector2(50, 200);
 var barrasede : float = 1;
 var sedevazia : Texture2D;
 var sedecheia : Texture2D;
 
 var ReducaoVida : int = 150;
 var ReducaoFome : int = 150;
 var ReducaoSede : int = 100;
 
 function Start () {
 
 }
 
 function Update () {
 if(barrafome <= 0 && (barrasede <= 0)){
 barravida -= Time.deltaTime / ReducaoVida * 2;
 }
 else
 {
 if(barrafome <= 0 || barrasede <= 0){
 barravida -= Time.deltaTime / ReducaoVida;
 }
 }
 
 if(barrafome >= 0){
 barrafome -= Time.deltaTime / ReducaoFome;
 }
     
 if(barrafome <= 0){
 barrafome = 0;
 }
     
 if(barrafome >= 1){
 barrafome = 1;
 }
 
 if(barrasede >= 0){
 barrasede -= Time.deltaTime / ReducaoSede;
 }
     
 if(barrasede <= 0){
 barrasede = 0;
 }
     
 if(barrasede >= 1){
 barrasede = 1;
 }
 }
 
 function OnGUI(){
 GUI.skin = skin;
 
 GUI.BeginGroup(new Rect (vida.x, vida.y, tamanhovida.x, tamanhovida.y));
 GUI.Box(Rect(0, 0, tamanhovida.x, tamanhovida.y), vidavazia);
 
 GUI.BeginGroup(new Rect (0, 0, tamanhovida.x * barravida, tamanhovida.y));
 GUI.Box(Rect(0, 0, tamanhovida.x, tamanhovida.y), vidacheia);
 
 GUI.EndGroup();
 GUI.EndGroup();
 
 GUI.BeginGroup(new Rect (fome.x, fome.y, tamanhofome.x, tamanhofome.y));
 GUI.Box(Rect(0, 0, tamanhofome.x, tamanhofome.y), fomevazia);
     
 GUI.BeginGroup(new Rect (0, 0, tamanhofome.x * barrafome, tamanhofome.y));
 GUI.Box(Rect(0, 0, tamanhofome.x, tamanhofome.y), fomecheia);
     
 GUI.EndGroup();
 GUI.EndGroup();
 
 GUI.BeginGroup(new Rect (sede.x, sede.y, tamanhosede.x, tamanhosede.y));
 GUI.Box(Rect(0, 0, tamanhosede.x, tamanhosede.y), sedevazia);
     
 GUI.BeginGroup(new Rect (0, 0, tamanhosede.x * barrasede, tamanhosede.y));
 GUI.Box(Rect(0, 0, tamanhosede.x, tamanhosede.y), sedecheia);
 
 GUI.EndGroup();
 GUI.EndGroup();
 
 }
Comment

People who like this

0 Show 0
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

1 Reply

· Add your reply
  • Sort: 
avatar image

Answer by Kiwasi · Mar 21, 2015 at 06:46 PM

Considered using a slider in the Unity UI tools? This makes the job trivial.

Comment

People who like this

0 Show 0 · Share
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

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Problem with HealthBar 1 Answer

Lifebar Help 1 Answer

Lerp sets value instantly, not interpolating it? 1 Answer

I need some help with a Fractional Heart System? 1 Answer

3d Object in GUI Layer 2 Answers


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