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
|
|
|
|
|
{
|
2023-04-01 16:08:32 +08:00
|
|
|
|
public uint sceneID = 0;
|
2023-02-28 06:49:40 +08:00
|
|
|
|
|
2023-04-01 16:08:32 +08:00
|
|
|
|
public GameObject levelTransistion;
|
2023-02-28 06:49:40 +08:00
|
|
|
|
|
2023-04-01 16:08:32 +08:00
|
|
|
|
private bool clickedFlag;
|
|
|
|
|
|
|
|
|
|
protected override void awake()
|
|
|
|
|
{
|
|
|
|
|
clickedFlag = false;
|
|
|
|
|
}
|
2023-02-03 22:44:02 +08:00
|
|
|
|
|
2023-04-01 16:08:32 +08:00
|
|
|
|
protected override void start()
|
|
|
|
|
{
|
|
|
|
|
UIElement ui = GetComponent<UIElement>();
|
|
|
|
|
if (ui != null)
|
2023-02-03 22:44:02 +08:00
|
|
|
|
{
|
2023-04-01 16:08:32 +08:00
|
|
|
|
ui.OnRelease.RegisterAction(() =>
|
|
|
|
|
{
|
|
|
|
|
if (sceneID != 0)
|
2023-02-04 00:04:25 +08:00
|
|
|
|
{
|
2023-04-01 16:08:32 +08:00
|
|
|
|
Audio.PlaySFXOnce2D("event:/UI/success");
|
|
|
|
|
Audio.StopAllSounds();
|
|
|
|
|
clickedFlag = true;
|
|
|
|
|
levelTransistion.SetActive(true);
|
2023-02-04 00:04:25 +08:00
|
|
|
|
}
|
2023-04-01 16:08:32 +08:00
|
|
|
|
});
|
2023-02-03 22:44:02 +08:00
|
|
|
|
}
|
2023-04-01 16:08:32 +08:00
|
|
|
|
else
|
2023-02-03 22:44:02 +08:00
|
|
|
|
{
|
2023-04-01 16:08:32 +08:00
|
|
|
|
Debug.LogError("Failed to register button action for ChangeSceneButton.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
protected override void update()
|
|
|
|
|
{
|
|
|
|
|
if (levelTransistion.GetScript<LevelTransistion>().complete && clickedFlag)
|
|
|
|
|
{
|
|
|
|
|
SceneManager.ChangeScene(sceneID);
|
2023-02-03 22:44:02 +08:00
|
|
|
|
}
|
2023-04-01 16:08:32 +08:00
|
|
|
|
}
|
2023-02-03 22:44:02 +08:00
|
|
|
|
}
|