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