Loading [MathJax]/jax/output/HTML-CSS/jax.js

Friday, September 20, 2019

Scene Loader in Unity

For loading scenes:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
 
public class SceneLoader : MonoBehaviour
{
    [SerializeField] int startScene = 0;
 
    public void LoadNextScene()
    {
        int currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
        SceneManager.LoadScene(currentSceneIndex + 1);
    }
 
    public void ReturnStartScene()
    {
        SceneManager.LoadScene(startScene);
    }
 
    public void QuitGame()
    {
        Application.Quit();
    }
 
    public void LoadGameOver()
    {
        SceneManager.LoadScene(2);
    }
}

No comments:

Post a Comment