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 /
avatar image
-1
Question by robert_mathew · Oct 04, 2011 at 10:10 PM · barprogress

progress bar

i am trying to create a health bar using draw texture it is working fine for me but the by using draw texture the texture itself is moving from its original position and how to increase the health bar from bottom to upward direction(- y direction).I want my texture should gradually increase from its original position to the clamped value with out moving the texture from its original position.Is any other method is there for health bar other than draw texture or how to use draw texture properly to get the result i want.

 http://answers.unity3d.com/questions/7846/how-do-i-make-a-progress-bar.html

i have tried the code used in above link for making a health bar it is working fine for me. The using above code the texture itself is moving from its original position i want the health bar should increase gradually from its original position. i want to increase health bar in (- y direction).in above code if i am fixing the texture position to var pos : Vector2 = new Vector2(20,40);

the whole texture starts move upwards.can you please fix this error in my coding as i am new to coding

Comment
Add comment · Show 1
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 vxssmatty · Oct 04, 2011 at 10:16 PM 0
Share

I really don't understand... can you edit this question so it is understandable? dot-points maybe?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Peter G · Oct 05, 2011 at 12:24 AM

I don't think you want to use DrawTexture(). You would be better off having an alpha-cutoff plane in the center of your screen and then lerp the alpha cutoff parameter as the time passes so that the entire progress bar is visible.

 var endTime : float = 10;
 // time is just one possible way you could lerp.  Player position is another.  Or score
 function Update () {
        var lerpParameter : float = 1 - Mathf.InverseLerp(0 , endTime , Time.time);
        //returns the lerp parameter between 2 values.
        renderer.material.SetFloat( "_Cutoff" , lerpParameter );
 }

The setup for this isn't too hard. Your progress bar needs to have a gradient alpha channel that fades from white to black (or black to white depending on which way you look at it ;) ). Then as time goes on, progressively more of the texture will be visible and you will have a progress bar.

Comment
Add comment · Show 1 · 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 robert_mathew · Oct 05, 2011 at 12:40 AM 0
Share

in my game i already have a texture called magical spell bar is there when player score increase the health of the player also increase in magical spell bar as yellow texture so i used above code i can i use draw texture to increase the health of the player when he get score in magical spell bar which is in rectangular shape in upwards direction(- y direction) from bottom to top direction

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

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

Modify circular progress bar based on a value? 1 Answer

Progress Bar 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