新增新手引导页
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -28,6 +28,10 @@ namespace GameFramework
|
||||
[SerializeField] GameObject creditsPanel;
|
||||
[SerializeField] Button creditsCloseButton;
|
||||
|
||||
[Header("新手引导")]
|
||||
[SerializeField] GameObject guidePanel;
|
||||
[SerializeField] Button guideStartButton;
|
||||
|
||||
void Start()
|
||||
{
|
||||
// 自动查找(解决场景重载后引用失效问题)
|
||||
@@ -59,6 +63,15 @@ namespace GameFramework
|
||||
if (creditsCloseButton == null && creditsPanel != null)
|
||||
creditsCloseButton = creditsPanel.GetComponentInChildren<Button>();
|
||||
|
||||
if (guidePanel == null)
|
||||
{
|
||||
// transform.Find 可以找到非激活的子对象
|
||||
var guideTr = transform.Find("GuidePanel");
|
||||
guidePanel = guideTr != null ? guideTr.gameObject : null;
|
||||
}
|
||||
if (guideStartButton == null && guidePanel != null)
|
||||
guideStartButton = guidePanel.GetComponentInChildren<Button>(true);
|
||||
|
||||
// 绑定按钮事件
|
||||
if (startButton != null)
|
||||
startButton.onClick.AddListener(OnStartClick);
|
||||
@@ -80,11 +93,16 @@ namespace GameFramework
|
||||
if (creditsCloseButton != null)
|
||||
creditsCloseButton.onClick.AddListener(OnCreditsCloseClick);
|
||||
|
||||
if (guideStartButton != null)
|
||||
guideStartButton.onClick.AddListener(OnGuideStartClick);
|
||||
|
||||
// 确保面板初始关闭
|
||||
if (settingsPanel != null)
|
||||
settingsPanel.SetActive(false);
|
||||
if (creditsPanel != null)
|
||||
creditsPanel.SetActive(false);
|
||||
if (guidePanel != null)
|
||||
guidePanel.SetActive(false);
|
||||
}
|
||||
|
||||
Button FindButton(string name)
|
||||
@@ -95,6 +113,24 @@ namespace GameFramework
|
||||
|
||||
void OnStartClick()
|
||||
{
|
||||
// 显示新手引导页,而非直接进入游戏
|
||||
if (guidePanel != null)
|
||||
{
|
||||
guidePanel.SetActive(true);
|
||||
Debug.Log("[MainMenu] 显示新手引导页");
|
||||
}
|
||||
else if (SceneLoader.Instance != null)
|
||||
{
|
||||
// 没有引导页则直接进入游戏
|
||||
SceneLoader.Instance.LoadGameplayScene();
|
||||
}
|
||||
}
|
||||
|
||||
void OnGuideStartClick()
|
||||
{
|
||||
if (guidePanel != null)
|
||||
guidePanel.SetActive(false);
|
||||
|
||||
if (SceneLoader.Instance != null)
|
||||
SceneLoader.Instance.LoadGameplayScene();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user