using System; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using Random = UnityEngine.Random; public class LoadingScreen : MonoBehaviour { public GameObject LoadingScreenUI; private Slider loadingSlider; public List tooltips = new List(); public PauseMenu pauseMenu; // Start is called once before the first execution of Update after the MonoBehaviour is created void Start() { pauseMenu.SetIsLoading(true); loadingSlider = LoadingScreenUI.GetComponentInChildren(); loadingSlider.value = 0f; } // Update is called once per frame void Update() { loadingSlider.value += 0.05f*Time.deltaTime; if (loadingSlider.value >= 1) { pauseMenu.SetIsLoading(false); LoadingScreenUI.SetActive(false); } } public void OnEnable() { ShowRandomTooltip(); } void ShowRandomTooltip() { if (tooltips.Count == 0) return; // Disable all tooltips first foreach (GameObject tooltip in tooltips) { tooltip.SetActive(false); } // Pick and enable one random tooltip int randomIndex = Random.Range(0, tooltips.Count); tooltips[randomIndex].SetActive(true); } }