Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by A_C · Jun 26, 2012 at 05:00 AM · javascriptguimenu

Stat bars in Menu system?

I'm making a racing game. In the menu, the player has the ability to choose which car they would like to use. Each car has 3 main stats, Top Speed, Acceleration, and Handling. I have a GUI Box with buttons that choose the players car, and set the 3 stats for that car. There is another box beside it that should show the stat bar for those values, but it remains blank. Here is the code for the stat bars:

 function statBars()
 {
 //Handling
     GUI.BeginGroup (new Rect (pos.x, pos.y, size.x, size.y));
     GUI.Box (Rect (100,100, size.x, size.y),progressBarEmpty, "Handling");
 
     // draw the filled-in part:
     GUI.BeginGroup (new Rect (0, 0, size.x * handle, size.y));
     GUI.Box (Rect (0,0, size.x, size.y),progressBarFull);
     GUI.EndGroup ();
 
     GUI.EndGroup ();
 //Speed 
     GUI.BeginGroup (new Rect (pos.x, pos.y - 20, size.x, size.y));
     GUI.Box (Rect (0,0, size.x, size.y),progressBarEmpty, "Top Speed");
 
     // draw the filled-in part:
     GUI.BeginGroup (new Rect (0, 0, size.x * speed, size.y));
     GUI.Box (Rect (0,0, size.x, size.y),progressBarFull);
     GUI.EndGroup ();
 
     GUI.EndGroup ();
 //Accelleration    
     GUI.BeginGroup (new Rect (pos.x, pos.y - 40, size.x, size.y));
     GUI.Box (Rect (0,0, size.x, size.y),progressBarEmpty, "Acceleration");
 
     // draw the filled-in part:
     GUI.BeginGroup (new Rect (0, 0, size.x * accl, size.y));
     GUI.Box (Rect (0,0, size.x, size.y),progressBarFull);
     GUI.EndGroup ();
 
     GUI.EndGroup ();
 
 }

Handle, Speed and accl are the variables set when the player chooses a car.

This is the code called when a player chooses a car:

 if (GUI.Button (Rect (Screen.width/3 -105, Screen.height/2+30,160,20), "1971 Dodge Charger")) {
         car = "Dodge Charger";
         speed = 85;
         accl = 90;
         handle = 50;
         statBars();
     }

I can't figure out how to make this work. Any help is greatly appreciated!!!

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Berenger · Jun 26, 2012 at 05:05 AM

You have a problem with your groups rects. The handling rect and the speed rect bot use size.y for height, and the speed's y (pos.y - 20) lead me to think that the size is around 20. However, the second group of handling has a rect with 100, 100.

You're making this more complicated than it should be. Simplify it and I bet the problem will stand out.

Comment
Add comment · 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.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

dropdown menu error 1 Answer

Making a Pause Menu 1 Answer

Menu Button help 1 Answer

How to make a scrollable menu like angry bird? 1 Answer

Dropdown button... 0 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