Health/Assets/Shift - Complete Sci-Fi UI/Scripts/Panel/SplashScreenManager.cs

84 lines
2.9 KiB
C#

using UnityEngine;
namespace Michsky.UI.Shift
{
public class SplashScreenManager : MonoBehaviour
{
[Header("Resources")]
public GameObject splashScreen;
public GameObject mainPanels;
private Animator splashScreenAnimator;
private Animator mainPanelsAnimator;
private TimedEvent ssTimedEvent;
[Header("Settings")]
public bool disableSplashScreen;
public bool enablePressAnyKeyScreen;
public bool enableLoginScreen;
MainPanelManager mpm;
void OnEnable()
{
if (splashScreenAnimator == null) { splashScreenAnimator = splashScreen.GetComponent<Animator>(); }
if (ssTimedEvent == null) { ssTimedEvent = splashScreen.GetComponent<TimedEvent>(); }
if (mainPanelsAnimator == null) { mainPanelsAnimator = mainPanels.GetComponent<Animator>(); }
if (mpm == null) { mpm = gameObject.GetComponent<MainPanelManager>(); }
if (disableSplashScreen == true)
{
splashScreen.SetActive(false);
mainPanels.SetActive(true);
mainPanelsAnimator.Play("Start");
mpm.OpenFirstTab();
}
if (enableLoginScreen == false && enablePressAnyKeyScreen == true && disableSplashScreen == false)
{
splashScreen.SetActive(true);
mainPanelsAnimator.Play("Invisible");
}
if (enableLoginScreen == true && enablePressAnyKeyScreen == true && disableSplashScreen == false)
{
splashScreen.SetActive(true);
mainPanelsAnimator.Play("Invisible");
}
if (enableLoginScreen == true && enablePressAnyKeyScreen == false && disableSplashScreen == false)
{
splashScreen.SetActive(true);
mainPanelsAnimator.Play("Invisible");
splashScreenAnimator.Play("Login");
}
if (enableLoginScreen == false && enablePressAnyKeyScreen == false && disableSplashScreen == false)
{
splashScreen.SetActive(true);
mainPanelsAnimator.Play("Invisible");
splashScreenAnimator.Play("Loading");
ssTimedEvent.StartIEnumerator();
}
}
public void LoginScreenCheck()
{
if (enableLoginScreen == true && enablePressAnyKeyScreen == true)
splashScreenAnimator.Play("Press Any Key to Login");
else if (enableLoginScreen == false && enablePressAnyKeyScreen == true)
{
splashScreenAnimator.Play("Press Any Key to Loading");
ssTimedEvent.StartIEnumerator();
}
else if (enableLoginScreen == false && enablePressAnyKeyScreen == false)
{
splashScreenAnimator.Play("Loading");
ssTimedEvent.StartIEnumerator();
}
}
}
}