jump-game/Jump Game/Assets/Scripts/Menu/ChangeScene.cs

29 lines
673 B
C#
Raw Normal View History

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class ChangeScene : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
2020-04-29 21:04:48 +00:00
if(SceneManager.GetActiveScene().buildIndex == 1)
{
StartCoroutine(ChangeSceneToGame(2));
}
if(SceneManager.GetActiveScene().buildIndex == 3)
{
StartCoroutine(ChangeSceneToGame(0));
}
}
2020-04-29 21:04:48 +00:00
private IEnumerator ChangeSceneToGame(int index)
{
yield return new WaitForSeconds(5);
2020-04-29 21:04:48 +00:00
SceneManager.LoadScene(index);
}
}