using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; using TMPro; namespace Saltosion.OneWeapon.GUI { public class WarningScreenController : MonoBehaviour { public TMP_Text ContinueText; public float ContinueTextFadeInTime; public float ContinueTextFadeInDelay; public float ContinueTextBlinkingDelay; public float ContinueTextBlinkingRate; public string MainMenuScene; private float StartTime; private void Start() { StartTime = Time.time; } private void Update() { if (Time.time - StartTime >= ContinueTextFadeInDelay) { // The text first fades in float T = Time.time - StartTime - ContinueTextFadeInDelay; float Progress = Mathf.Clamp(T / ContinueTextFadeInTime, 0, 1); if (T > ContinueTextBlinkingDelay) { // Then starts blinking after fading in Progress -= (Mathf.Sin((T - ContinueTextBlinkingDelay - 0.5f) * Mathf.PI * 2.0f * ContinueTextBlinkingRate) * 0.5f + 0.5f) * 0.7f; } ContinueText.alpha = Progress; } else { ContinueText.alpha = 0.0f; } if (Input.anyKey) { SceneManager.LoadScene(MainMenuScene); } } } }