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 /
This question was closed Mar 07, 2015 at 10:11 PM by KnightRiderGuy for the following reason:

Solved with another question

avatar image
0
Question by KnightRiderGuy · Dec 13, 2014 at 01:27 AM · timerhealthbartimer countdown

Oxygen Tank Progress Bar

Is there a way to make a bar made out of a GUI texture slowly scale down along the X Axis over time? I basically have a 3 layer GUI set up where there is an overlay and a background bar that I would like to have scale down slowly over time to indicate that something like Oxygen is running out.

I was looking at how health bars are made but non of them seemed to be the sort of thing I am after. Does anyone know of an easy way to do this?

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

  • Sort: 
avatar image
0

Answer by Kiwasi · Dec 13, 2014 at 01:57 AM

Are you version constrained in Unity? If not I would upgrade to Unity 4.6 and use a Slider. This makes the job trivial, simple set Slider.value to whatever number you like.

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 KnightRiderGuy · Dec 13, 2014 at 01:26 PM 0
Share

$$anonymous$$aybe but I just need to do something with a simple script as I may add features to it later that seem kind of difficult to do with the new UI feature. For instance I find some elements are hard to layer with the new UI system and some of my animations get buried under the new UI even if I try making them a child of the canvas or panel. So for this screen which is pretty self contained all I need is something simple that will make the bar, in this case a big rectangle behind an overlay to extinguish over a set time, preferably a time I can either set with buttons or just in the inspector for now.

I tried using this idea but I could not seem to get this to layer behind my overlay GUI full screen texture.

 static var curHp : float = 300.0;
 static var maxHp : float = 300.0;
  static var guiDepth : int = 2;
 var HpBarTexture : Texture2D;
 
 var hpBarLength : float;
 var percentOfHp : float;
 
  
  
 function OnGUI () {
          GUI.depth = guiDepth;
         if (curHp > 0) {
                 GUI.depth = 2;
                 GUI.DrawTexture(Rect ((Screen.width/2) - 365, 112, hpBarLength, 255), HpBarTexture);
         }
 }
  
 function Update () {
  
         percentOfHP = curHp/maxHp;
         hpBarLength = percentOfHP*700;
  
  
         if(Input.Get$$anonymous$$eyDown("h")) {
                 curHp -= 10.0;
         }
  
 }

Follow this Question

Answers Answers and Comments

26 People are following this question.

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

Related Questions

timer not ticking down 2 Answers

How do I make the timeScale not affect the timer? 1 Answer

Timer not working in prefabs 0 Answers

how to make the timer stop and can automatically proceed to the next scene 0 Answers

How do I make a Countdown Timer in Minutes and Seconds only 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