Files
unity-application/Assets/Common/Scripts/ChangeSceneOnClick.cs
Dries Van Schuylenbergh 26f3322e4e Add formatting rules
2023-03-10 09:21:11 +00:00

36 lines
1019 B
C#

using UnityEngine;
using UnityEngine.SceneManagement;
/// <summary>
/// Class to handle scene loading callbacks
/// </summary>
public class ChangeSceneOnClick : MonoBehaviour
{
/// <summary>
/// Method used as callback for gameobject onClick events
/// </summary>
/// <param name="sceneName">The path to the new scene (<c>path == $"Assets/{sceneName}"</c>)</param>
public void LoadScene(string sceneName)
{
SceneManager.LoadScene(sceneName);
}
/// <summary>
/// Method used as callback for gameobject onClick events
/// </summary>
/// <param name="scene">Reference to a scene</param>
public void LoadScene(Scene scene)
{
SceneManager.LoadScene(scene.buildIndex);
}
/// <summary>
/// Method used as callback from gameobject onClick events
/// </summary>
/// <param name="buildIndex">Build index of the scene to be loaded</param>
public void LoadScene(int buildIndex)
{
SceneManager.LoadScene(buildIndex);
}
}