Search code examples
c#unity-game-engineunityscriptunity3d-gui

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.


Solution

  • 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;
        }
    }