I’m trying to create a delay between the start button press and the scene transition … Anyone know why it doesn’t work?
using UnityEngine;
using UnityEngine.SceneManagement;
using TMPro;
using System.Collections;
/// <summary>
/// Controling scene
/// </summary>
public class SceneManeger : MonoBehaviour
{
private bool _press = false; //check if press
public TextMeshProUGUI start; //Start menu font
private float _wait = 3.0f; //delay
private void Update()
{
CheckPress();
}
public void LoadScene(string sceneLoad)
{
_press = true; //start CheckPress()
Debug.Log("button was pressed");
StartCoroutine(WaitSec(_wait)); //delay between change scene
Debug.Log("corutine Start");
SceneManager.LoadScene(sceneLoad); //Load GameMode scene
print("Scene Load");
}
//Method to change the font size if start button press
void CheckPress()
{
if (_press == true)
start.fontSize = 45;
}
// make delay between butten press and scene load
IEnumerator WaitSec(float sec)
{
yield return new WaitForSeconds(sec);
}
}