更新,spine和很多优化
This commit is contained in:
@@ -3,6 +3,7 @@ using UnityEngine.UI;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.SceneManagement;
|
||||
using System.Collections.Generic;
|
||||
using Bansonic;
|
||||
|
||||
public class btmandtopController : MonoBehaviour
|
||||
{
|
||||
@@ -17,6 +18,19 @@ public class btmandtopController : MonoBehaviour
|
||||
public Button showLevel_display;
|
||||
public Button email_display;
|
||||
public Button notice_display;
|
||||
public Button market_launch;
|
||||
|
||||
[Header("User Guide")]
|
||||
[SerializeField] private Button userGuideButton;
|
||||
[SerializeField] private Image guideDisplayImage;
|
||||
[SerializeField] private List<GuideMapping> guideMappings;
|
||||
|
||||
[System.Serializable]
|
||||
public struct GuideMapping
|
||||
{
|
||||
public string sceneName;
|
||||
public Sprite guideSprite;
|
||||
}
|
||||
|
||||
public Button button_Music;
|
||||
[Header("MusicPic")]
|
||||
@@ -40,6 +54,20 @@ public class btmandtopController : MonoBehaviour
|
||||
[SerializeField] private string homeSceneName = "UI_UI";
|
||||
[SerializeField] private string backFallbackSceneName = "Main_main";
|
||||
|
||||
[Header("Scene Navigation Rules")]
|
||||
[Tooltip("Define explicit back-navigation targets for specific scenes. This overrides the history-based navigation.")]
|
||||
[SerializeField] private List<SceneNavigationRule> navigationRules;
|
||||
|
||||
[System.Serializable]
|
||||
public struct SceneNavigationRule
|
||||
{
|
||||
public string sceneName;
|
||||
[Tooltip("The scene to return to. If empty, falls back to history.")]
|
||||
public string backTargetScene;
|
||||
[Tooltip("Optional: Visual depth indicator (0=Root, 1=Chapter, etc)")]
|
||||
public int depth;
|
||||
}
|
||||
|
||||
private UnityAction instantiateSettings;
|
||||
private UnityAction instantiateUserInfo;
|
||||
private UnityAction instantiateStore;
|
||||
@@ -49,6 +77,8 @@ public class btmandtopController : MonoBehaviour
|
||||
private UnityAction navBackAction;
|
||||
private UnityAction navHomeAction;
|
||||
private UnityAction navSettingsAction;
|
||||
private UnityAction navGuideAction;
|
||||
private UnityAction instantiateMarket;
|
||||
|
||||
// cached reference to the settings instance to ensure only one exists
|
||||
private GameObject settingsInstance;
|
||||
@@ -84,11 +114,16 @@ public class btmandtopController : MonoBehaviour
|
||||
}
|
||||
}
|
||||
instantiateSettings = () => ToggleSettingsPrefab();
|
||||
instantiateUserInfo = () => InstantiatePrefab(userInfo_prefab);
|
||||
instantiateUserInfo = () => { gNotice.recommendation.display("功能即将上线,敬请期待"); };
|
||||
instantiateStore = () => InstantiatePrefab(store_prefab);
|
||||
instantiateShowLevel = () => ShowLevelPrefab();
|
||||
instantiateEmail = () => ShowEmailPrefab();
|
||||
instantiateNotice = () => ShowNoticePrefab();
|
||||
instantiateShowLevel = () => { gNotice.error.display("功能即将下线,禁止访问"); };
|
||||
// instantiateShowLevel = () => ShowLevelPrefab();
|
||||
instantiateEmail = () => { gNotice.warning.display("此版本该功能暂不可用"); };
|
||||
// instantiateEmail = () => ShowEmailPrefab();
|
||||
instantiateNotice = () => { gNotice.warning.display("此版本该功能暂不可用"); };
|
||||
// instantiateNotice = () => ShowNoticePrefab();
|
||||
navGuideAction = () => ToggleGuideDisplay();
|
||||
instantiateMarket = () => { gNotice.alarm.display("商店未开放"); };
|
||||
|
||||
if (settings_launch != null)
|
||||
settings_launch.onClick.AddListener(instantiateSettings);
|
||||
@@ -102,6 +137,10 @@ public class btmandtopController : MonoBehaviour
|
||||
email_display.onClick.AddListener(instantiateEmail);
|
||||
if (notice_display != null)
|
||||
notice_display.onClick.AddListener(instantiateNotice);
|
||||
if (market_launch != null)
|
||||
market_launch.onClick.AddListener(instantiateMarket);
|
||||
if (userGuideButton != null)
|
||||
userGuideButton.onClick.AddListener(navGuideAction);
|
||||
|
||||
BindNewBackButtons();
|
||||
|
||||
@@ -328,6 +367,10 @@ public class btmandtopController : MonoBehaviour
|
||||
email_display.onClick.RemoveListener(instantiateEmail);
|
||||
if (notice_display != null)
|
||||
notice_display.onClick.RemoveListener(instantiateNotice);
|
||||
if (market_launch != null)
|
||||
market_launch.onClick.RemoveListener(instantiateMarket);
|
||||
if (userGuideButton != null)
|
||||
userGuideButton.onClick.RemoveListener(navGuideAction);
|
||||
|
||||
if (button_Music != null)
|
||||
button_Music.onClick.RemoveListener(ToggleMusicPicLocal);
|
||||
@@ -340,6 +383,46 @@ public class btmandtopController : MonoBehaviour
|
||||
settings_navButton.onClick.RemoveListener(navSettingsAction);
|
||||
}
|
||||
|
||||
private void ToggleGuideDisplay()
|
||||
{
|
||||
if (guideDisplayImage == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (guideDisplayImage.gameObject.activeSelf)
|
||||
{
|
||||
guideDisplayImage.gameObject.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
string currentScene = SceneManager.GetActiveScene().name;
|
||||
Sprite targetSprite = null;
|
||||
|
||||
if (guideMappings != null)
|
||||
{
|
||||
foreach (var mapping in guideMappings)
|
||||
{
|
||||
if (mapping.sceneName == currentScene)
|
||||
{
|
||||
targetSprite = mapping.guideSprite;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (targetSprite != null)
|
||||
{
|
||||
guideDisplayImage.sprite = targetSprite;
|
||||
guideDisplayImage.gameObject.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
gNotice.warning.display("未找到指引信息");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ToggleSettingsPrefab()
|
||||
{
|
||||
if (settings_prefab == null || putPrefabsHere == null) return;
|
||||
@@ -608,7 +691,28 @@ public class btmandtopController : MonoBehaviour
|
||||
InitializeSceneHistoryIfNeeded();
|
||||
|
||||
string current = SceneManager.GetActiveScene().name ?? string.Empty;
|
||||
string target = PopPreviousSceneName(current);
|
||||
string target = null;
|
||||
|
||||
if (navigationRules != null)
|
||||
{
|
||||
foreach (var rule in navigationRules)
|
||||
{
|
||||
if (string.Equals(rule.sceneName, current, System.StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(rule.backTargetScene))
|
||||
{
|
||||
target = rule.backTargetScene;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(target))
|
||||
{
|
||||
target = PopPreviousSceneName(current);
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(target))
|
||||
{
|
||||
target = string.IsNullOrEmpty(backFallbackSceneName) ? "Main_main" : backFallbackSceneName;
|
||||
|
||||
Reference in New Issue
Block a user