Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unity3d progress bar

I am developing a game using unity3D and I need help making a progress time bar such that on collecting particular items time is added and thus the game continues.

like image 580
A.Njuguna Avatar asked Dec 08 '22 02:12

A.Njuguna


1 Answers

Create a UI Image that is of type Filled. Use horizontal or vertical fill depending on your progress bar. Then from inside a script you can manipulate the value of the image. I will give you a very simple c# example. For the rest you can just use google and read the unity scripting API.

public class Example: MonoBehaviour {

    public Image progress;

    // Update is called once per frame
    void Update () 
    {
            progress.fillAmount -=  Time.deltaTime;
    }
}
like image 62
Uri Popov Avatar answered Dec 10 '22 15:12

Uri Popov