-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathChangeScene.cs
25 lines (21 loc) · 857 Bytes
/
ChangeScene.cs
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
//using UnityEngine.SceneManagement;
/// <summary>
/// A script to change the scene when colliding with a trigger
/// </summary>
/// <param name="levelIndex">Index of the scene that should be changed to. The index can be found at "Build Settings" -> "Scenes in Build" at the end of a row.</param>
public class ChangeScene : MonoBehaviour
{
public int levelIndex;
// Start is called before the first frame update
void Start() { }
//when entering the trigger, the Scene will be changed to the given levelIndex
//the index can be found at "Build Settings" -> "Scenes in Build" at the end of a row
private void OnTriggerEnter(Collider other)
{
UnityEngine.SceneManagement.SceneManager.LoadScene(levelIndex);
}
}