27 lines
729 B
C#
27 lines
729 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
namespace NEG.UI.UnityUi.Buttons
|
|
{
|
|
[RequireComponent(typeof(BaseButton))]
|
|
public class ChangeSceneButton : MonoBehaviour
|
|
{
|
|
[Header("Leave empty to use int value")]
|
|
[SerializeField] private string sceneName;
|
|
|
|
[SerializeField] private int sceneIndex;
|
|
|
|
private void Awake() => GetComponent<BaseButton>().OnButtonPressed += OnClicked;
|
|
|
|
private void OnClicked()
|
|
{
|
|
if (string.IsNullOrEmpty(sceneName))
|
|
SceneManager.LoadScene(sceneIndex);
|
|
else
|
|
SceneManager.LoadScene(sceneName);
|
|
}
|
|
}
|
|
}
|