36 lines
1.1 KiB
C#
36 lines
1.1 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UIElements;
|
|
|
|
namespace VOID.UserInterface.LoadingScreen
|
|
{
|
|
public class LoadingScreenUI : MonoBehaviour
|
|
{
|
|
public static LoadingScreenUI current { get; private set; }
|
|
|
|
// Visual Elements
|
|
private VisualElement _rootElement;
|
|
private VisualElement _progressBarElement;
|
|
|
|
private void Awake()
|
|
{
|
|
current = this;
|
|
|
|
var uiDocument = gameObject.GetComponent<UIDocument>();
|
|
var templateElement = uiDocument.rootVisualElement;
|
|
|
|
// Find all important elements
|
|
_rootElement = templateElement.Q("root-loading-screen");
|
|
_progressBarElement = templateElement.Q("progress-bar");
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sets progress which change length of loading bar.
|
|
/// </summary>
|
|
/// <param name="progress">Value between 0 and 1</param>
|
|
public void SetProgress(float progress)
|
|
{
|
|
_progressBarElement.style.width = new StyleLength(Length.Percent(Mathf.Clamp01(progress) * 100));
|
|
}
|
|
}
|
|
}
|