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 AlexJBoyd · May 14, 2012 at 04:59 PM · barprogressprogress barvisualize

Progress Bar

Last time you guys were so much help, I thought I would try it again.

I am trying to create a progress bar that will increase along with the player's score. Once the bar hits the specified amount, the bar will reset and it will activate the multiplier. I understand the "back end" part of what I am trying to do. However, I am having trouble visualizing it for the player.

So my question is: How do I visualize a progress, that will adjust in size with a variable?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Berenger · May 14, 2012 at 05:31 PM

I usually do progress bar with a group and a texture. The tricky part is to find the %

 var percentage : float = 1.0; // Up to you here, something like current / max
 GUI.BeginGroup( Rect( 10, 10, 100 * percentage, 10 ) );
     GUI.DrawTexture( Rect( 10, 10, 100, 10 ), tex ); // Note the 100 for the width
 GUI.EndGroup();

tex can be a white texture of size (1,1), that way you can change the color with GUI.color. Now, for the multiplier, that concerns the percentage calculation.

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
avatar image
0

Answer by hathol · May 14, 2012 at 05:20 PM

I would do something along the lines of

 float t = (currentScore-startScore)/(maxScore-startScore); 
 float maxWidth = 400; //the total width of your progress bar 
 yourGUITexture.pixelInset = new Rect(0, 0, maxWidth * t, 50);

You basically get the percentage of the filled bar and scale your bar by that value.

Comment
Add comment · Show 6 · 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
avatar image hathol · May 14, 2012 at 05:28 PM 0
Share

Sry for all the edits, I'm still trying to get a hang of that markdown stuff :)

avatar image AlexJBoyd · May 14, 2012 at 05:33 PM 0
Share

Using this answer as spark, I was wondering:

Could I use a a normal cube, and then adjust its size using a transform?

avatar image Berenger · May 14, 2012 at 05:36 PM 0
Share

A regular cube you mean ? It can be done, but it's a bit harder than GUI stuff. It involves an orthographic camera and a script to transpose screen coordinate to world coordinate.

avatar image AlexJBoyd · May 14, 2012 at 05:39 PM 0
Share

$$anonymous$$y mistake, (I am still trying to get used to asking questions where people know no info) but the camera is actually orthographic. However, a follow up would be: which is more resource efficient, GUI or a cube on screen?

avatar image Berenger · May 14, 2012 at 05:46 PM 0
Share

Not sure, but I don't think either would have a big impact on performance.

Show more comments

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

6 People are following this question.

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

Related Questions

progress bar 1 Answer

How to create a vertical circular progress bar 1 Answer

Problem ProgressBar with health + Time the poison 1 Answer

Progress of loading level 1 Answer

Best way to make an animated infinite striped progress bar? 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