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
1
Question by sam32x · Dec 13, 2011 at 07:14 AM · healthbarsomething

scrollbar

code:

 var health = 50;
 
 function OnGUI () {
 GUI.HorizontalScrollbar (Rect (25, 25, 50, 10), 0, 10, health, 10);
 }

i want the bar to start at the left and be longer if health is higher but i forgot what numbers to put where

Comment
Add comment · Show 9
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 CHPedersen · Dec 13, 2011 at 07:46 AM 2
Share

Then consult the documentation. GUI.HorizontalScrollbar is easily googled:

http://unity3d.com/support/documentation/ScriptReference/GUI.HorizontalScrollbar.html

Its page tells you exactly what each parameter is.

avatar image sam32x · Dec 13, 2011 at 11:13 AM 0
Share

i read that but i didnt understand it

avatar image CHPedersen · Dec 13, 2011 at 11:32 AM 0
Share

What about it didn't you understand?

avatar image Lo0NuhtiK · Dec 13, 2011 at 03:02 PM 0
Share

Watch this video tutorial on How to make a health bar , it should help. The GUI part of it starts around 06:30 or so. The parameter's should still work basically the same for your scrollbar if that's really what you want to use for it. There's a lot of other unity health bar stuff all over the place in here too if you just search for it.

avatar image sam32x · Dec 14, 2011 at 11:28 PM 0
Share

i didnt understand which numbers to put where and my internet is so bad that a video that is more than 6:30 will take over an hour to load

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by aldonaletto · Dec 15, 2011 at 01:06 AM

That's an interesting "misuse" of this function - it's intended to control something, not to show a value - but yes, it can be used as a progress bar:

var health: float = 50; var maxHealth: float = 100; var dummy: float = 0; // "sticks" the button at the left

function OnGUI () { GUI.HorizontalScrollbar (Rect (25, 25, 120, 20), dummy, health, 0, maxHealth); } You must never allow the health to be lower than zero or greater than maxHealth, or the bar will grow to the wrong side (to the left). Another problem is that the bar never reaches zero length, even with zero health (and negative health will make it grow to the left, as mentioned above).

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

9 People are following this question.

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

Related Questions

manabar doesnt work 1 Answer

expressions in statements must only be executed for their side effects 1 Answer

object rotating around parent 1 Answer

calculating the midpoint of two objects 4 Answers

how to make a gui scrollbar render below another gui scrollbar 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