Neg_Utils/NEG/UI/UnityUi/Buttons/ChangeSceneButton.cs

26 lines
657 B
C#

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace NEG.UI.UnityUi.Buttons
{
[RequireComponent(typeof(BaseButton))]
public class ChangeSceneButton : ButtonReaction
{
[Header("Leave empty to use int value")]
[SerializeField] private string sceneName;
[SerializeField] private int sceneIndex;
protected override void OnClicked()
{
if (string.IsNullOrEmpty(sceneName))
SceneManager.LoadScene(sceneIndex);
else
SceneManager.LoadScene(sceneName);
}
}
}