using System.Collections; using UnityEngine; using UnityEngine.EventSystems; namespace Michsky.UI.Heat { [DisallowMultipleComponent] public class MenuManager : MonoBehaviour { public UIManager UIManagerAsset; public Animator splashScreen; [SerializeField] private GameObject mainContent; [SerializeField] private ImageFading initPanel; private float splashInTime; private float splashOutTime; public static bool bypassSplashScreen; private void Awake() { Time.timeScale = 1f; if (initPanel != null) { initPanel.gameObject.SetActive(value: true); } if (splashScreen != null) { splashScreen.gameObject.SetActive(value: false); } } private void Start() { StartCoroutine("StartInitialize"); } public void DisableSplashScreen() { StopCoroutine("DisableSplashScreenAnimator"); StartCoroutine("FinalizeSplashScreen"); splashScreen.enabled = true; splashScreen.Play("Out"); } private void Initialize() { if (UIManagerAsset == null || mainContent == null) { Debug.LogError("[Heat UI] Cannot initialize the resources due to missing resources.", this); return; } mainContent.gameObject.SetActive(value: false); if (!bypassSplashScreen && UIManagerAsset.enableSplashScreen) { if (splashScreen == null) { Debug.LogError("[Heat UI] Splash Screen is enabled but its resource is missing. Please assign the correct variable for 'Splash Screen'.", this); return; } AnimationClip[] animationClips = splashScreen.runtimeAnimatorController.animationClips; splashInTime = animationClips[0].length; splashOutTime = animationClips[1].length; splashScreen.enabled = true; splashScreen.gameObject.SetActive(value: true); StartCoroutine("DisableSplashScreenAnimator"); if (UIManagerAsset.showSplashScreenOnce) { bypassSplashScreen = true; } } else if (mainContent == null) { Debug.LogError("[Heat UI] 'Main Panels' is missing. Please assign the correct variable for 'Main Panels'.", this); } else { if (splashScreen != null) { splashScreen.gameObject.SetActive(value: false); } mainContent.gameObject.SetActive(value: false); StartCoroutine("FinalizeSplashScreen"); } } private IEnumerator StartInitialize() { yield return new WaitForSeconds(0.5f); if (initPanel != null) { initPanel.FadeOut(); } Initialize(); } private IEnumerator DisableSplashScreenAnimator() { yield return new WaitForSeconds(splashInTime + 0.1f); splashScreen.enabled = false; } private IEnumerator FinalizeSplashScreen() { yield return new WaitForSeconds(splashOutTime + 0.1f); if (UIManagerAsset != null && UIManagerAsset.enableSplashScreen) { splashScreen.gameObject.SetActive(value: false); } mainContent.gameObject.SetActive(value: true); if (ControllerManager.instance != null && ControllerManager.instance.gamepadEnabled && ControllerManager.instance.firstSelected != null && ControllerManager.instance.firstSelected.activeInHierarchy) { EventSystem.current.SetSelectedGameObject(ControllerManager.instance.firstSelected); } } } }