Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Tutorial: Animate runtime progress bars with UI Toolkit

Discussion in 'UI Toolkit' started by Yecats, Mar 20, 2021.

  1. Yecats

    Yecats

    Joined:
    Jul 13, 2014
    Posts:
    69

    A lot goes into creating an intuitive experience for your player. Progress bars are often used to reassure the player that something is happening (such as the game loading) or give them an idea on how long something will take. In this tutorial, you will learn some techniques for creating and animating progress bars using UI Toolkit and DOTween.

    Learning Outcomes
    UI Toolkit does not have the ability to do masking, nor does it hook directly into the Animation system. You will learn techniques for working around these two limitations. At the end of the tutorial, you will be able to
    1. Design UIs by using the UI Builder tool.
    2. Add a runtime UI to your game.
    3. Animate the UI through DOTween
    4. Hook up DOTween animations to trigger at a specific point of a complicated character animation using Animation Events.
    Prerequisites
    1. You need Unity 2020.3.0f1 (LTS) or later to follow along with this tutorial.
    2. This tutorial assumes you already have basic knowledge of Unity and intermediate knowledge of C#.
    Note: Tutorials may work with earlier versions. The version referenced is the on I used.

    1-final.gif
     
    Last edited: Oct 13, 2023
  2. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    378
    Thanks for this tutorial. I'm starting learning UI Toolkit and it's perfect to understand the principle.
    I followed carefully your explanation, but there is something missing in
    1) Design 1 – Animate the progress bar
    the invoke of AnimateLoadingBar:
    //Wait 2 seconds before starting the animation
    Invoke("AnimateLoadingBar", 2f);
    Not a problem, I found the solutnio in your git

    2) when I run the demo, I got an error
    upload_2023-9-17_19-39-22.png


    Component is not found:
    m_Root = GetComponent<UIDocument>().rootVisualElement;

    3) I tried to load your project from git and found a script missing:
    upload_2023-9-17_19-41-11.png

    Could you give me some directions?

    Thank a lot
    Thierry
     
  3. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    378
    Sorry, I found how to. I was just stupid!