修复bug 增加选关
This commit is contained in:
@@ -47,6 +47,13 @@ namespace AibisDream
|
||||
#else
|
||||
runMode = RunMode.Product;
|
||||
#endif
|
||||
}
|
||||
public void StartWithTalkSceneSO(TalkSceneSO sceneSO)
|
||||
{
|
||||
_currentTalkSceneSo = sceneSO;
|
||||
StartCoroutine(LoadScene());
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void StartNewGame()
|
||||
@@ -67,6 +74,13 @@ namespace AibisDream
|
||||
StartMenu.Instance.HideStartMenu();
|
||||
DialogController.Instance.StartDialog(_currentTalkSceneSo.yarnProject);
|
||||
}
|
||||
private IEnumerator LoadScene()
|
||||
{
|
||||
yield return SceneLoader.Instance.LoadSceneAsync(_currentTalkSceneSo.firstSceneName);
|
||||
StartMenu.Instance.HideStartMenu();
|
||||
DialogController.Instance.StartDialog(_currentTalkSceneSo.yarnProject);
|
||||
MainUIController.Instance.HideMainUI();
|
||||
}
|
||||
|
||||
public IEnumerator NextSceneSo()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
|
||||
namespace AibisDream
|
||||
{
|
||||
public class SceneSelectionUIController : MonoBehaviour
|
||||
{
|
||||
[Header("UI References")]
|
||||
public GameObject panel; // 用于显示选择界面的面板
|
||||
public Button buttonPrefab; // 按钮预制体
|
||||
public Transform buttonParent; // 按钮容器,用来放置动态创建的按钮
|
||||
|
||||
public Button returnButton;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// 确保场景选择面板开始时是隐藏的
|
||||
panel.SetActive(false);
|
||||
}
|
||||
|
||||
public void ShowSceneSelection(TalkSceneSO[] sceneSos)
|
||||
{
|
||||
// 清空当前的按钮
|
||||
foreach (Transform child in buttonParent)
|
||||
{
|
||||
Destroy(child.gameObject);
|
||||
}
|
||||
|
||||
// 动态创建按钮
|
||||
foreach (var sceneSo in sceneSos)
|
||||
{
|
||||
Button button = Instantiate(buttonPrefab, buttonParent);
|
||||
button.GetComponentInChildren<TMP_Text>().text = sceneSo.nameToPlayer;
|
||||
button.onClick.AddListener(() => OnSceneSelected(sceneSo));
|
||||
returnButton.onClick.AddListener(() => close());
|
||||
}
|
||||
|
||||
// 显示选择面板
|
||||
panel.SetActive(true);
|
||||
}
|
||||
|
||||
private void OnSceneSelected(TalkSceneSO selectedScene)
|
||||
{
|
||||
// 在场景管理器中加载选定的场景
|
||||
GameLoopManager.Instance.StartWithTalkSceneSO(selectedScene);
|
||||
panel.SetActive(false); // 隐藏选择面板
|
||||
|
||||
}
|
||||
private void close()
|
||||
{
|
||||
panel.SetActive(false);
|
||||
}
|
||||
private void Update() {
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.A) && Input.GetKey(KeyCode.L))
|
||||
{
|
||||
DialogController.Instance.StopDialog();
|
||||
ShowSceneSelection(GameLoopManager.Instance.totalSceneSos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cab16ae41506a78418b49a1606ec0178
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -13,6 +13,8 @@ namespace AibisDream {
|
||||
[SerializeField] private Button quitButton;
|
||||
|
||||
[SerializeField] private GameObject startTab;
|
||||
|
||||
[SerializeField] private SceneSelectionUIController sceneSelection;
|
||||
[SerializeField] private GameObject levelTab;
|
||||
[SerializeField] private GameObject buttonPrefab;
|
||||
|
||||
@@ -41,9 +43,8 @@ namespace AibisDream {
|
||||
}
|
||||
|
||||
private void SwitchToLevelTab()
|
||||
{
|
||||
startTab.SetActive(false);
|
||||
levelTab.SetActive(true);
|
||||
{
|
||||
sceneSelection.ShowSceneSelection(GameLoopManager.Instance.totalSceneSos);
|
||||
}
|
||||
|
||||
private void SwitchToStartTab()
|
||||
|
||||
@@ -13,6 +13,8 @@ namespace AibisDream
|
||||
public string firstSceneName;
|
||||
|
||||
public bool isEndOfDay;
|
||||
|
||||
public string nameToPlayer;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user