更新,spine和很多优化

This commit is contained in:
FloatGaming
2026-02-24 05:36:08 +08:00
parent 14fb281d6f
commit d5c8966abd
2039 changed files with 348643 additions and 2589 deletions
+30 -10
View File
@@ -1,4 +1,4 @@
/*
/*
* FancyScrollView (https://github.com/setchi/FancyScrollView)
* Copyright (c) 2020 setchi
* Licensed under MIT (https://github.com/setchi/FancyScrollView/blob/master/LICENSE)
@@ -22,6 +22,14 @@ class UI_Panel_Character : MonoBehaviour
[SerializeField] Image Image_Character_Illustration;
[SerializeField] Image Image_Character_Illustration_BG;
[Header("Data Paths")]
[Tooltip("Path relative to Resources folder for Editor mode")]
public string editorResourcePath = "so/ally";
[Tooltip("Path relative to Resources folder for Runtime mode")]
public string runtimeResourcePath = "so/ally";
private List<AllyHero_SO> allyHeroList = new List<AllyHero_SO>();
private void Update()
{
if (Input.GetKeyDown(KeyCode.Escape))
@@ -46,15 +54,24 @@ class UI_Panel_Character : MonoBehaviour
item.speed = Anim_Speed;
}
content_Character_Slot.Get_Childrens_Component<UI_Button_Character_Head_Slot>(true, true);
for (int i = 0; i < UI_Panel_Main.Singleton.Data_List.Count; i++)
// Load AllyHero_SO data
string path = Application.isEditor ? editorResourcePath : runtimeResourcePath;
var loadedData = Resources.LoadAll<AllyHero_SO>(path);
allyHeroList = new List<AllyHero_SO>(loadedData);
// Ensure consistent order with UI_Panel_Main
allyHeroList.Sort((a, b) => a.ally_heroID.CompareTo(b.ally_heroID));
for (int i = 0; i < allyHeroList.Count; i++)
{
var obj = Instantiate(button_Character_Slot_Prefab, content_Character_Slot);
var data = UI_Panel_Main.Singleton.Data_List[i];
obj.image.sprite = data.Image_Head;
var data = allyHeroList[i];
obj.image.sprite = data.ally_hero_squareProfile;
if (obj.TryGetComponent(out UI_Button_Character_Head_Slot head_Slot))
{
head_Slot.index = data.index;
obj.onClick.AddListener(() => Set_Character_Index(head_Slot.index));
head_Slot.index = i;
int capturedIndex = i;
obj.onClick.AddListener(() => Set_Character_Index(capturedIndex));
}
}
}
@@ -82,16 +99,19 @@ class UI_Panel_Character : MonoBehaviour
}
public void Set_Character_Show()
{
var data = UI_Panel_Main.Singleton.Get_Character_Image_Data();
int index = UI_Panel_Main.Singleton.Character_Index;
if (allyHeroList == null || index < 0 || index >= allyHeroList.Count) return;
var data = allyHeroList[index];
var pos1 = Image_Character_Illustration.rectTransform.anchoredPosition;
Image_Character_Illustration.sprite = data.Image_Full;
Image_Character_Illustration.sprite = data.ally_hero_HD_image;
DOTween.To(value =>
{ Image_Character_Illustration.rectTransform.anchoredPosition = new Vector2(value, pos1.y); },
startValue: Image_Character_Illustration.rectTransform.anchoredPosition.x - 200,
pos1.x, anim_Time);
Image_Character_Illustration.SetNativeSize();
var pos = Image_Character_Illustration_BG.rectTransform.anchoredPosition;
Image_Character_Illustration_BG.sprite = data.Image_Full;
Image_Character_Illustration_BG.sprite = data.ally_hero_HD_image;
DOTween.To(value =>
{ Image_Character_Illustration_BG.rectTransform.anchoredPosition = new Vector2(value, pos.y); },
startValue: Image_Character_Illustration_BG.rectTransform.anchoredPosition.x - 200,
@@ -100,7 +120,7 @@ class UI_Panel_Character : MonoBehaviour
Image_Character_Illustration_BG.transform.localScale = new(2.7f, 2.7f, 2.7f);
string text = text_Character_Name.text;
string text = data.ally_heroName;
var t = DOTween.To(() => string.Empty, value => text_Character_Name.text = value, text, anim_Time).SetEase(Ease.Linear);
t.SetOptions(true);
}
+38 -30
View File
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
@@ -7,6 +7,7 @@ using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using Bansonic;
public class UI_Panel_Main : Singleton_Mono<UI_Panel_Main>
{
@@ -15,13 +16,14 @@ public class UI_Panel_Main : Singleton_Mono<UI_Panel_Main>
set
{
character_Index = value;
Set_Character_Illustration(Get_Character_Image_Data(character_Index).Image_Full);
if(character_Index >= 0 && character_Index < data_List.Count)
Set_Character_Illustration(Get_Character_Image_Data(character_Index).ally_hero_HD_image);
}
get => character_Index;
}
public int character_Index = 1;
[SerializeField] List<Character_Data_Image_SO> data_List;
public List<Character_Data_Image_SO> Data_List => data_List;
public int character_Index = 0;
[SerializeField] List<AllyHero_SO> data_List = new List<AllyHero_SO>();
public List<AllyHero_SO> Data_List => data_List;
[SerializeField] Button button_Character_Set;
[SerializeField] GameObject ui_Panel_Character;
[SerializeField] Button button_Encyclopendia;
@@ -250,10 +252,8 @@ public class UI_Panel_Main : Singleton_Mono<UI_Panel_Main>
protected override void OnDestroy()
{
Kill_Enter_Tweens();
foreach (var item in data_List)
{
Destroy(item);
}
// data_List contains references to assets in Resources, do not Destroy them.
data_List.Clear();
base.OnDestroy();
}
private void Start()
@@ -263,24 +263,16 @@ public class UI_Panel_Main : Singleton_Mono<UI_Panel_Main>
private IEnumerator InitDataRoutine()
{
var rawData = Resources.LoadAll<Character_Data_Image_SO>("Data");
data_List = new List<Character_Data_Image_SO>();
var rawData = Resources.LoadAll<AllyHero_SO>("so/ally");
data_List = new List<AllyHero_SO>(rawData);
for (int i = 0; i < rawData.Length; i++)
{
var item = rawData[i];
if (item == null) continue;
var so = Instantiate(item);
data_List.Add(so);
// Documentation text normalized.
{
yield return null;
}
}
data_List.Sort((a, b) => a.ally_heroID.CompareTo(b.ally_heroID));
yield return null;
Character_Index = character_Index;
if(Character_Index >= 0 && Character_Index < data_List.Count)
Set_Character_Illustration(Get_Character_Image_Data(Character_Index).ally_hero_HD_image);
if (button_Character_Set != null)
button_Character_Set.onClick.AddListener(
@@ -297,10 +289,24 @@ public class UI_Panel_Main : Singleton_Mono<UI_Panel_Main>
Character_Index = character_Index;
if (button_Encyclopendia != null)
button_Encyclopendia.onClick.AddListener(
() => Try_Open_Panel(ui_Panel_Encyclopendia));
() =>
{
gNotice.warning.display("此版本未开放该功能");
//Try_Open_Panel(ui_Panel_Encyclopendia);
});
if (button_Story != null)
button_Story.onClick.AddListener(
() => Try_Open_Panel(ui_Panel_Story));
() =>
{
gNotice.warning.display("此版本未开放该功能");
//Try_Open_Panel(ui_Panel_Story);
});
if (button_Idol != null)
button_Idol.onClick.AddListener(
() =>
{
gNotice.warning.display("此版本未开放该功能");
});
if (music_Player != null && music_Player.Button_List != null)
music_Player.Button_List.onClick.AddListener(
() => Try_Open_Panel(ui_Panel_Music));
@@ -677,13 +683,15 @@ public class UI_Panel_Main : Singleton_Mono<UI_Panel_Main>
}
}
}
public Character_Data_Image_SO Get_Character_Image_Data(int index)
public AllyHero_SO Get_Character_Image_Data(int index)
{
return data_List.Find(i => i.index == index);
if(index < 0 || index >= data_List.Count) return null;
return data_List[index];
}
public Character_Data_Image_SO Get_Character_Image_Data()
public AllyHero_SO Get_Character_Image_Data()
{
return data_List.Find(i => i.index == character_Index);
if(character_Index < 0 || character_Index >= data_List.Count) return null;
return data_List[character_Index];
}
public void Set_Character_Illustration(Sprite sprite)
{
@@ -75,6 +75,81 @@ MonoBehaviour:
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &280150709295593380
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2318280567031044456}
- component: {fileID: 1023961900524064665}
- component: {fileID: 2438452334951697137}
m_Layer: 0
m_Name: wenhao
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!224 &2318280567031044456
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 280150709295593380}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4008714089197239054}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 1920, y: 1080}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &1023961900524064665
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 280150709295593380}
m_CullTransparentMesh: 1
--- !u!114 &2438452334951697137
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 280150709295593380}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 0
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 0
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &406175461848920595
GameObject:
m_ObjectHideFlags: 0
@@ -109,8 +184,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 63.8, y: -8.5}
m_SizeDelta: {x: 160, y: 30}
m_AnchoredPosition: {x: 15.268383, y: 0}
m_SizeDelta: {x: 88.937, y: 30.263}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &8834825946409292425
CanvasRenderer:
@@ -147,13 +222,13 @@ MonoBehaviour:
m_BestFit: 0
m_MinSize: 10
m_MaxSize: 40
m_Alignment: 0
m_Alignment: 4
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: 114514
m_Text: NaN
--- !u!1 &438562227820009306
GameObject:
m_ObjectHideFlags: 0
@@ -1005,6 +1080,7 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 291470585847424768}
- component: {fileID: 8373938424588989755}
m_Layer: 5
m_Name: MusicPic
m_TagString: Untagged
@@ -1055,6 +1131,24 @@ RectTransform:
m_AnchoredPosition: {x: -628.13, y: -267.01}
m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &8373938424588989755
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1162878931044217181}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 99786ec25b14ff7428d7f2ced0b24b89, type: 3}
m_Name:
m_EditorClassIdentifier:
guide: {fileID: 0}
entry:
path: MusicPic
text: "\u8FD9\u4E9B\u662F\u6211\u4ECE\u623F\u95F4\u91CC\u641C\u96C6\u6765\u7684\uFF0C\u60A8\u6311\u4E24\u9996\uFF1F\u4E0D\u5FC5\u5728\u610F\u6211\u5BF9\u60A8\u54C1\u5473\u7684\u770B\u6CD5\u3002\u4E0D\u8FC7\u5728\u67D0\u4E9B\u60C5\u51B5\u4E0B...\u6211\u662F\u4F1A\u5207\u6389\u7684\u54E6\u3002"
iconPath: "Assets/artworks/Ul_Ul/\u65B0\u7248\u4E3B\u754C\u9762\uFF082\uFF09/\u97F3\u4E50"
icon: {fileID: 7605814977653748970, guid: fd7da29c38f47ea4695ec23268ebdd9d, type: 3}
--- !u!1 &1207165874131126891
GameObject:
m_ObjectHideFlags: 0
@@ -3396,7 +3490,7 @@ MonoBehaviour:
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: Outline
m_Text: "\u79BB\u7EBF\u6A21\u5F0F"
--- !u!1 &3339318652266806984
GameObject:
m_ObjectHideFlags: 0
@@ -4339,6 +4433,7 @@ RectTransform:
- {fileID: 6434860682258445909}
- {fileID: 5634981615641515618}
- {fileID: 291470585847424768}
- {fileID: 2318280567031044456}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
@@ -4412,6 +4507,20 @@ MonoBehaviour:
showLevel_display: {fileID: 5868241863521704767}
email_display: {fileID: 7520904819348953829}
notice_display: {fileID: 920723299105391293}
market_launch: {fileID: 5379967691629323644}
userGuideButton: {fileID: 6945238783669072533}
guideDisplayImage: {fileID: 2438452334951697137}
guideMappings:
- sceneName: UI_UI
guideSprite: {fileID: 0}
- sceneName: selectYourSongFirst
guideSprite: {fileID: 0}
- sceneName: Songs_Select
guideSprite: {fileID: 0}
- sceneName: gamePlay_gamePlay
guideSprite: {fileID: 0}
- sceneName:
guideSprite: {fileID: 0}
button_Music: {fileID: 5472029888669800656}
musicPicRoot: {fileID: 0}
showMusicPicInUI: 1
@@ -4428,6 +4537,22 @@ MonoBehaviour:
settings_navButton: {fileID: 0}
homeSceneName: UI_UI
backFallbackSceneName: Main_main
navigationRules:
- sceneName: UI_UI
backTargetScene: Main_main
depth: 0
- sceneName: selectYourSongFirst
backTargetScene: UI_UI
depth: 1
- sceneName: Songs_Select
backTargetScene: selectYourSongFirst
depth: 2
- sceneName: gamePlay_gamePlay
backTargetScene: selectYourSongFirst
depth: 3
- sceneName:
backTargetScene:
depth: 4
--- !u!114 &2510911207525280717
MonoBehaviour:
m_ObjectHideFlags: 0
@@ -4937,8 +5062,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 6.300003, y: -29.900002}
m_SizeDelta: {x: 200, y: 50}
m_AnchoredPosition: {x: -68.0999, y: -29.900002}
m_SizeDelta: {x: 222.8, y: 50}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &6137481741208887361
CanvasRenderer:
@@ -4969,19 +5094,19 @@ MonoBehaviour:
m_PersistentCalls:
m_Calls: []
m_FontData:
m_Font: {fileID: 12800000, guid: dfa10de3e2846524089b5073175cd151, type: 3}
m_FontSize: 30
m_Font: {fileID: 12800000, guid: bc54bd51ea8b84448ba1b65311872862, type: 3}
m_FontSize: 24
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 10
m_MinSize: 1
m_MaxSize: 40
m_Alignment: 4
m_Alignment: 5
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: XXXX
m_Text: username
--- !u!1 &5909026714256705340
GameObject:
m_ObjectHideFlags: 0
@@ -6655,8 +6780,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 63.8, y: -8.5}
m_SizeDelta: {x: 160, y: 30}
m_AnchoredPosition: {x: 18.268383, y: -0.00012207031}
m_SizeDelta: {x: 82.937, y: 30.263}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &9087867391651096042
CanvasRenderer:
@@ -6693,13 +6818,13 @@ MonoBehaviour:
m_BestFit: 0
m_MinSize: 10
m_MaxSize: 40
m_Alignment: 0
m_Alignment: 4
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: 114514
m_Text: NaN
--- !u!1 &7869453618975110451
GameObject:
m_ObjectHideFlags: 0
@@ -7740,11 +7865,11 @@ MonoBehaviour:
m_PersistentCalls:
m_Calls: []
m_FontData:
m_Font: {fileID: 12800000, guid: dfa10de3e2846524089b5073175cd151, type: 3}
m_FontSize: 36
m_Font: {fileID: 12800000, guid: bc54bd51ea8b84448ba1b65311872862, type: 3}
m_FontSize: 24
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 10
m_MinSize: 2
m_MaxSize: 61
m_Alignment: 3
m_AlignByGeometry: 0
@@ -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;
+75 -8
View File
@@ -1,4 +1,4 @@
using UnityEngine;
using UnityEngine;
using System;
using System.Collections;
using UnityEngine.SceneManagement;
@@ -72,7 +72,22 @@ public class PauseManager : MonoBehaviour
ResolveOverlayRootForPausePrefab();
EnsureOverlayCanvasGroup();
EnsureOverlayPanelRoot();
SetOverlayVisibleImmediate(false);
// Ensure CanvasGroup is initialized to 0 alpha, but keep interactable/blocksRaycasts true
if (overlayCanvasGroup != null)
{
overlayCanvasGroup.alpha = 0f;
overlayCanvasGroup.interactable = true;
overlayCanvasGroup.blocksRaycasts = true;
}
// Initialize buttons but DO NOT call SetOverlayVisibleImmediate(false) here
// because it would reset the flags we just set.
// Instead, we manually ensure the object is active if that's the desired initial state,
// or just rely on the alpha=0 to hide it.
// Assuming user wants the object active but transparent:
if (overlayRoot != null) overlayRoot.SetActive(true);
TryBindButtons(force: true);
}
@@ -96,9 +111,16 @@ public class PauseManager : MonoBehaviour
if (Input.GetKeyDown(KeyCode.Escape))
{
// User requested ESC as pause trigger in gameplay only.
if (CanPauseFromInput() && !IsPaused)
if (CanPauseFromInput())
{
Pause(true);
if (!IsPaused)
{
Pause(true);
}
else
{
Pause(false);
}
}
}
@@ -118,13 +140,47 @@ public class PauseManager : MonoBehaviour
IsPaused = true;
Time.timeScale = 0f;
OnPauseStateChanged?.Invoke(true);
// Startup flows call Pause(true) before real gameplay starts.
// In that phase we keep time paused but do not show pause UI.
bool allowOverlay = CanPauseFromInput();
// Calculate allowOverlay WITHOUT checking IsPaused (since we just set it to true).
bool allowOverlay = true;
if (onlyInGameplayScene && !IsGameplaySceneActive()) allowOverlay = false;
else if (requirePlaybackStarted)
{
var gm = FindAnyObjectByType<GameManager>();
// If GM missing or playback not started, don't show overlay yet
if (gm != null && !gm.PlaybackStarted) allowOverlay = false;
}
if (allowOverlay)
{
ShowOverlayAnimated(true);
}
else
SetOverlayVisibleImmediate(false);
{
// Startup Pause State:
// Keep object active and blocking raycasts (per user request), but invisible.
if (overlayRoot != null) overlayRoot.SetActive(true);
if (overlayCanvasGroup != null)
{
overlayCanvasGroup.alpha = 0f;
overlayCanvasGroup.interactable = true;
overlayCanvasGroup.blocksRaycasts = true;
}
if (overlayPanelCanvasGroup != null)
{
overlayPanelCanvasGroup.alpha = 0f;
overlayPanelCanvasGroup.interactable = true;
overlayPanelCanvasGroup.blocksRaycasts = true;
}
if (overlayPanelRoot != null)
overlayPanelRoot.localScale = PanelHiddenScale;
}
}
else
{
@@ -186,19 +242,30 @@ public class PauseManager : MonoBehaviour
var gm = FindAnyObjectByType<GameManager>();
if (gm == null) return false;
// If already paused, allow input to unpause regardless of PlaybackStarted state
if (IsPaused) return true;
return gm.PlaybackStarted;
}
private void EnsureOverlayCanvasGroup()
{
if (overlayRoot == null) return;
overlayCanvasGroup = overlayRoot.GetComponent<CanvasGroup>();
if (overlayCanvasGroup == null)
// Priority: Use existing CanvasGroup if available (Index first)
if (!overlayRoot.TryGetComponent(out overlayCanvasGroup))
{
// Fallback: Create only if not found
overlayCanvasGroup = overlayRoot.AddComponent<CanvasGroup>();
}
}
private void ResolveOverlayRootForPausePrefab()
{
// Priority: If manually assigned in Inspector, respect it.
if (overlayRoot != null) return;
if (!preferPausePrefabOverWhiteScreen) return;
// Prefer the real pause prefab root (contains Continue/Replay/Exit).
GameObject pauseRoot = FindPauseMenuRootInScene();
@@ -662,20 +662,4 @@ public class UI_FunctionHoverGuide : MonoBehaviour
}
}
public class UI_FunctionHoverTarget : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
{
public UI_FunctionHoverGuide guide;
public UI_FunctionHoverEntry entry;
public void OnPointerEnter(PointerEventData eventData)
{
if (guide != null && entry != null)
guide.ApplyEntry(entry);
}
public void OnPointerExit(PointerEventData eventData)
{
if (guide != null && entry != null)
guide.ClearEntry(entry);
}
}
@@ -0,0 +1,20 @@
using UnityEngine;
using UnityEngine.EventSystems;
public class UI_FunctionHoverTarget : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
{
public UI_FunctionHoverGuide guide;
public UI_FunctionHoverEntry entry;
public void OnPointerEnter(PointerEventData eventData)
{
if (guide != null && entry != null)
guide.ApplyEntry(entry);
}
public void OnPointerExit(PointerEventData eventData)
{
if (guide != null && entry != null)
guide.ClearEntry(entry);
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 99786ec25b14ff7428d7f2ced0b24b89