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(); var templateElement = uiDocument.rootVisualElement; // Find all important elements _rootElement = templateElement.Q("root-loading-screen"); _progressBarElement = templateElement.Q("progress-bar"); } /// /// Sets progress which change length of loading bar. /// /// Value between 0 and 1 public void SetProgress(float progress) { _progressBarElement.style.width = new StyleLength(Length.Percent(Mathf.Clamp01(progress) * 100)); } } }