| | 1 | | using TMPro; |
| | 2 | | using UnityEngine; |
| | 3 | | using UnityEngine.UI; |
| | 4 | |
|
| | 5 | | namespace DCL.LoadingScreen |
| | 6 | | { |
| | 7 | | /// <summary> |
| | 8 | | /// View responsible of showing the corresponding loading percentage and message provided by LoadingScreenPercen |
| | 9 | | /// </summary> |
| | 10 | | public class LoadingScreenPercentageView : MonoBehaviour |
| | 11 | | { |
| | 12 | | [SerializeField] internal TMP_Text loadingMessage; |
| | 13 | | [SerializeField] internal Image loadingPercentage; |
| 0 | 14 | | private readonly string LOADING_AVATAR_MESSAGE = "Loading avatar..."; |
| 0 | 15 | | private readonly string LOADING_SCENE_MESSAGE = "Loading scenes, 3D models, and sounds... {0}% complete"; |
| 0 | 16 | | private readonly string COMPILING_SHADERS_MESSAGE = "Compiling shaders, this might take a few seconds"; |
| | 17 | | private string currentMessage; |
| | 18 | |
|
| | 19 | | public void SetLoadingPercentage(int percentage) |
| | 20 | | { |
| 0 | 21 | | loadingMessage.text = GetCurrentLoadingMessage(percentage); |
| 0 | 22 | | loadingPercentage.fillAmount = percentage / 100f; |
| 0 | 23 | | } |
| | 24 | |
|
| | 25 | | internal string GetCurrentLoadingMessage(int percentage) => |
| 0 | 26 | | string.Format(currentMessage, percentage); |
| | 27 | |
|
| | 28 | | public void SetSceneLoadingMessage() => |
| 0 | 29 | | currentMessage = LOADING_SCENE_MESSAGE; |
| | 30 | |
|
| | 31 | | public void SetPlayerLoadingMessage() => |
| 0 | 32 | | currentMessage = LOADING_AVATAR_MESSAGE; |
| | 33 | |
|
| | 34 | | public void SetShaderCompilingMessage(float progress) |
| | 35 | | { |
| 0 | 36 | | loadingMessage.text = COMPILING_SHADERS_MESSAGE; |
| 0 | 37 | | loadingPercentage.fillAmount = progress; |
| 0 | 38 | | } |
| | 39 | |
|
| | 40 | | } |
| | 41 | | } |