2023-03-03 21:07:59 +08:00
|
|
|
using System;
|
2023-03-02 16:26:49 +08:00
|
|
|
using System.Reflection.Metadata.Ecma335;
|
|
|
|
using SHADE;
|
|
|
|
using SHADE_Scripting.UI;
|
|
|
|
|
|
|
|
public class ChangeSceneButton : Script
|
|
|
|
{
|
|
|
|
public uint sceneID = 0;
|
|
|
|
|
|
|
|
//Whether the scene changing button has been clicked
|
|
|
|
private bool clickedFlag;
|
|
|
|
|
|
|
|
protected override void awake()
|
|
|
|
{
|
|
|
|
clickedFlag = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void start()
|
|
|
|
{
|
|
|
|
UIElement ui = GetComponent<UIElement>();
|
|
|
|
if (ui != null)
|
|
|
|
{
|
|
|
|
ui.OnRelease.RegisterAction(() =>
|
|
|
|
{
|
|
|
|
if (sceneID != 0)
|
|
|
|
{
|
2023-03-03 21:07:59 +08:00
|
|
|
Audio.PlaySFXOnce2D("event:/UI/success");
|
|
|
|
Audio.StopAllSounds();
|
|
|
|
if (SceneFadeInOut.Instance != null)
|
2023-03-02 16:26:49 +08:00
|
|
|
SceneFadeInOut.Instance.CallFadeIn();
|
2023-03-03 21:07:59 +08:00
|
|
|
clickedFlag = true;
|
2023-03-02 16:26:49 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Debug.LogError("Failed to register button action for ChangeSceneButton.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
protected override void update()
|
|
|
|
{
|
|
|
|
if (clickedFlag && sceneID != 0 && SceneFadeInOut.Instance.FadeInFinished())
|
|
|
|
{
|
|
|
|
SceneManager.ChangeScene(sceneID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|