UI换了很多,spine主视觉停用
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 07cd0a4415d4a6349bdf669e82011dfa
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,157 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public static class UIBackStack
|
||||
{
|
||||
private sealed class Entry
|
||||
{
|
||||
public UnityEngine.Object owner;
|
||||
public Func<bool> canHandle;
|
||||
public Func<bool> handleBack;
|
||||
public long sequence;
|
||||
}
|
||||
|
||||
private static readonly List<Entry> entries = new List<Entry>();
|
||||
private static long nextSequence;
|
||||
private static bool hookedSceneEvents;
|
||||
|
||||
public static void RegisterOrBump(UnityEngine.Object owner, Func<bool> canHandle, Func<bool> handleBack)
|
||||
{
|
||||
if (owner == null || handleBack == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EnsureSceneHook();
|
||||
PurgeInvalidEntries();
|
||||
|
||||
for (int i = 0; i < entries.Count; i++)
|
||||
{
|
||||
Entry existing = entries[i];
|
||||
if (ReferenceEquals(existing.owner, owner))
|
||||
{
|
||||
existing.canHandle = canHandle;
|
||||
existing.handleBack = handleBack;
|
||||
existing.sequence = ++nextSequence;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
entries.Add(new Entry
|
||||
{
|
||||
owner = owner,
|
||||
canHandle = canHandle,
|
||||
handleBack = handleBack,
|
||||
sequence = ++nextSequence
|
||||
});
|
||||
}
|
||||
|
||||
public static void Unregister(UnityEngine.Object owner)
|
||||
{
|
||||
if (owner == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = entries.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (ReferenceEquals(entries[i].owner, owner))
|
||||
{
|
||||
entries.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static bool TryHandleTop()
|
||||
{
|
||||
EnsureSceneHook();
|
||||
PurgeInvalidEntries();
|
||||
|
||||
entries.Sort((a, b) => a.sequence.CompareTo(b.sequence));
|
||||
|
||||
for (int i = entries.Count - 1; i >= 0; i--)
|
||||
{
|
||||
Entry entry = entries[i];
|
||||
if (!CanEntryHandle(entry))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (entry.handleBack())
|
||||
{
|
||||
PurgeInvalidEntries();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"[UIBackStack] HandleBack failed: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
PurgeInvalidEntries();
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool CanEntryHandle(Entry entry)
|
||||
{
|
||||
if (entry == null || entry.owner == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return entry.canHandle == null || entry.canHandle();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"[UIBackStack] CanHandle failed: {ex.Message}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static void PurgeInvalidEntries()
|
||||
{
|
||||
for (int i = entries.Count - 1; i >= 0; i--)
|
||||
{
|
||||
Entry entry = entries[i];
|
||||
if (entry == null || entry.owner == null)
|
||||
{
|
||||
entries.RemoveAt(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (entry.owner is Behaviour behaviour && behaviour.gameObject == null)
|
||||
{
|
||||
entries.RemoveAt(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (entry.owner is GameObject ownerGo && ownerGo == null)
|
||||
{
|
||||
entries.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void EnsureSceneHook()
|
||||
{
|
||||
if (hookedSceneEvents)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
hookedSceneEvents = true;
|
||||
SceneManager.sceneLoaded += HandleSceneLoaded;
|
||||
}
|
||||
|
||||
private static void HandleSceneLoaded(Scene scene, LoadSceneMode mode)
|
||||
{
|
||||
PurgeInvalidEntries();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a260537100e6b8f48971e79e1f97c306
|
||||
@@ -10,6 +10,8 @@ public class UI_CharacterDialogController : MonoBehaviour
|
||||
[SerializeField] private string requiredSceneName = "UI_UI";
|
||||
[SerializeField] private string characterObjectName = "Image_Character";
|
||||
[SerializeField] private string dialogObjectName = "UI_DIALOG";
|
||||
[SerializeField] private RectTransform characterObject;
|
||||
[SerializeField] private RectTransform dialogObject;
|
||||
|
||||
[Header("Enter")]
|
||||
[SerializeField] private float enterDuration = 0.3f;
|
||||
@@ -127,7 +129,9 @@ public class UI_CharacterDialogController : MonoBehaviour
|
||||
if (!scene.IsValid() || !scene.isLoaded)
|
||||
scene = SceneManager.GetActiveScene();
|
||||
|
||||
Transform dialogTr = FindInSceneByName(scene, dialogObjectName);
|
||||
Transform dialogTr = dialogObject;
|
||||
if (dialogTr == null)
|
||||
dialogTr = FindInSceneByName(scene, dialogObjectName);
|
||||
if (dialogTr == null)
|
||||
dialogTr = FindInSceneByName(SceneManager.GetActiveScene(), dialogObjectName);
|
||||
if (dialogTr != null)
|
||||
@@ -155,7 +159,9 @@ public class UI_CharacterDialogController : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
Transform characterTr = FindInSceneByName(scene, characterObjectName);
|
||||
Transform characterTr = characterObject;
|
||||
if (characterTr == null)
|
||||
characterTr = FindInSceneByName(scene, characterObjectName);
|
||||
if (characterTr == null)
|
||||
characterTr = FindInSceneByName(SceneManager.GetActiveScene(), characterObjectName);
|
||||
if (characterTr != null)
|
||||
@@ -409,6 +415,13 @@ static class UI_CharacterDialogControllerBootstrap
|
||||
if (!string.Equals(scene.name, SceneName, System.StringComparison.OrdinalIgnoreCase))
|
||||
return;
|
||||
|
||||
UI_CharacterDialogController existing = FindControllerInScene(scene);
|
||||
if (existing != null)
|
||||
{
|
||||
existing.RebindSoon();
|
||||
return;
|
||||
}
|
||||
|
||||
GameObject host = FindHostInScene(scene, HostName);
|
||||
if (host == null)
|
||||
{
|
||||
@@ -422,6 +435,23 @@ static class UI_CharacterDialogControllerBootstrap
|
||||
controller.RebindSoon();
|
||||
}
|
||||
|
||||
private static UI_CharacterDialogController FindControllerInScene(Scene scene)
|
||||
{
|
||||
if (!scene.IsValid() || !scene.isLoaded)
|
||||
return null;
|
||||
|
||||
UI_CharacterDialogController[] controllers = UnityEngine.Object.FindObjectsByType<UI_CharacterDialogController>(FindObjectsInactive.Include, FindObjectsSortMode.None);
|
||||
for (int i = 0; i < controllers.Length; i++)
|
||||
{
|
||||
UI_CharacterDialogController controller = controllers[i];
|
||||
if (controller == null)
|
||||
continue;
|
||||
if (controller.gameObject.scene == scene)
|
||||
return controller;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static GameObject FindHostInScene(Scene scene, string hostName)
|
||||
{
|
||||
if (!scene.IsValid() || !scene.isLoaded)
|
||||
|
||||
@@ -326,7 +326,7 @@ public class UI_Panel_Mail : MonoBehaviour
|
||||
|
||||
bool ShouldUseServerMail()
|
||||
{
|
||||
return fetchMailsFromServer && Application.isPlaying;
|
||||
return fetchMailsFromServer && Application.isPlaying && OnlineModeSettings.IsOnlineEnabled;
|
||||
}
|
||||
|
||||
void OnMailRead(mailSlotPrefab slot, mail_so mail)
|
||||
@@ -359,7 +359,7 @@ public class UI_Panel_Mail : MonoBehaviour
|
||||
{
|
||||
if (!MailRewardGrantService.TryGrantAll(mail, out string failureMessage))
|
||||
{
|
||||
gNotice.error.display(string.IsNullOrWhiteSpace(failureMessage) ? "\u90ae\u4ef6\u5956\u52b1\u9886\u53d6\u5931\u8d25" : failureMessage);
|
||||
gNotice.error.display(string.IsNullOrWhiteSpace(failureMessage) ? LocalizationService.Get("mail.claim_failed", "邮件奖励领取失败") : failureMessage);
|
||||
return;
|
||||
}
|
||||
mail.isReceived = true;
|
||||
@@ -1021,6 +1021,11 @@ public class MailHttpService : MonoBehaviour
|
||||
|
||||
public void SetServerModeEnabled(bool enabled)
|
||||
{
|
||||
if (OnlineModeSettings.IsLocalOnlyMode)
|
||||
{
|
||||
enabled = false;
|
||||
}
|
||||
|
||||
if (_serverModeEnabled == enabled)
|
||||
{
|
||||
if (enabled && _pollCoroutine == null)
|
||||
@@ -1050,7 +1055,7 @@ public class MailHttpService : MonoBehaviour
|
||||
|
||||
public void RequestRefresh()
|
||||
{
|
||||
if (!_serverModeEnabled || _isRefreshing)
|
||||
if (!_serverModeEnabled || _isRefreshing || OnlineModeSettings.IsLocalOnlyMode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -1157,7 +1162,7 @@ public class MailHttpService : MonoBehaviour
|
||||
|
||||
public async System.Threading.Tasks.Task NotifyMailClaimedAsync(int mailId)
|
||||
{
|
||||
if (!_serverModeEnabled || mailId <= 0)
|
||||
if (!_serverModeEnabled || mailId <= 0 || OnlineModeSettings.IsLocalOnlyMode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -1193,7 +1198,7 @@ public class MailHttpService : MonoBehaviour
|
||||
|
||||
private async System.Threading.Tasks.Task SyncClaimedMailStateAsync()
|
||||
{
|
||||
if (!_serverModeEnabled || _cachedMails.Count == 0)
|
||||
if (!_serverModeEnabled || _cachedMails.Count == 0 || OnlineModeSettings.IsLocalOnlyMode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -162,6 +162,7 @@ public class UI_Panel_Main : Singleton_Mono<UI_Panel_Main>
|
||||
[SerializeField] RectTransform top_PlayerName;
|
||||
[SerializeField] RectTransform button_Character_Set_Rect;
|
||||
[SerializeField] RectTransform launch_EzGame_Rect;
|
||||
[SerializeField] UI_CharacterDialogController character_Dialog_Controller;
|
||||
|
||||
[Header("Jiantou Loop")]
|
||||
[SerializeField] bool play_Jiantou_Loop = true;
|
||||
@@ -317,7 +318,7 @@ public class UI_Panel_Main : Singleton_Mono<UI_Panel_Main>
|
||||
button_Story.onClick.AddListener(
|
||||
() =>
|
||||
{
|
||||
gNotice.warning.display("姝ょ増鏈湭寮€鏀捐鍔熻兘");
|
||||
gNotice.warning.display("此版本未开放该功能");
|
||||
//Try_Open_Panel(ui_Panel_Story);
|
||||
});
|
||||
if (button_Idol != null)
|
||||
@@ -336,7 +337,7 @@ public class UI_Panel_Main : Singleton_Mono<UI_Panel_Main>
|
||||
worldChatObject.SetActive(false);
|
||||
if (button_worldChat != null && worldChatObject != null)
|
||||
button_worldChat.onClick.AddListener(
|
||||
() => worldChatObject.SetActive(true));
|
||||
() => OpenManagedPanel(worldChatObject));
|
||||
|
||||
|
||||
if (button_Select_Music != null)
|
||||
@@ -361,6 +362,7 @@ public class UI_Panel_Main : Singleton_Mono<UI_Panel_Main>
|
||||
enterAnim.enabled = true;
|
||||
}
|
||||
panel.SetActive(true);
|
||||
RegisterManagedPanel(panel);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -386,6 +388,7 @@ public class UI_Panel_Main : Singleton_Mono<UI_Panel_Main>
|
||||
}
|
||||
|
||||
panel.SetActive(true);
|
||||
RegisterManagedPanel(panel);
|
||||
}
|
||||
|
||||
GameObject Try_Open_Prefab(GameObject prefab, ref GameObject instance)
|
||||
@@ -399,9 +402,42 @@ public class UI_Panel_Main : Singleton_Mono<UI_Panel_Main>
|
||||
AssignPrefabCanvasCamera(instance);
|
||||
if (!instance.activeSelf) instance.SetActive(true);
|
||||
Play_Prefab_Enter(instance);
|
||||
RegisterManagedPanel(instance);
|
||||
return instance;
|
||||
}
|
||||
|
||||
void OpenManagedPanel(GameObject panel)
|
||||
{
|
||||
if (panel == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
panel.SetActive(true);
|
||||
RegisterManagedPanel(panel);
|
||||
}
|
||||
|
||||
void RegisterManagedPanel(GameObject panel)
|
||||
{
|
||||
if (panel == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UIBackStack.RegisterOrBump(
|
||||
panel,
|
||||
() => panel != null && panel.activeInHierarchy,
|
||||
() =>
|
||||
{
|
||||
if (panel != null)
|
||||
{
|
||||
panel.SetActive(false);
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
void AssignPrefabCanvasCamera(GameObject instance)
|
||||
{
|
||||
if (instance == null) return;
|
||||
@@ -498,6 +534,16 @@ public class UI_Panel_Main : Singleton_Mono<UI_Panel_Main>
|
||||
return;
|
||||
}
|
||||
|
||||
if (character_Dialog_Controller != null)
|
||||
{
|
||||
if (!character_Dialog_Controller.enabled)
|
||||
{
|
||||
character_Dialog_Controller.enabled = true;
|
||||
}
|
||||
character_Dialog_Controller.RebindSoon();
|
||||
return;
|
||||
}
|
||||
|
||||
GameObject host = null;
|
||||
Transform[] all = UnityEngine.Object.FindObjectsByType<Transform>(FindObjectsInactive.Include, FindObjectsSortMode.None);
|
||||
for (int i = 0; i < all.Length; i++)
|
||||
|
||||
@@ -227,7 +227,7 @@ public class UI_Panel_Note : MonoBehaviour
|
||||
image_Character_Illustration.sprite = Resources.Load<Sprite>(data.data.image_Name);
|
||||
text_Character_RealName.text = data.data.realName;
|
||||
text_Character_StageName.text = data.data.stageName;
|
||||
text_Character_Gender.text = data.data.stageName;
|
||||
text_Character_Gender.text = data.data.gender;
|
||||
text_Character_Age.text = data.data.age.ToString();
|
||||
text_Character_Height.text = data.data.height.ToString();
|
||||
text_Character_Weight.text = data.data.weight.ToString();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.SceneManagement;
|
||||
@@ -159,7 +159,7 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
button_Music = btn.GetComponent<Button>();
|
||||
if (button_Music == null)
|
||||
{
|
||||
var any = FindByName("Button_Music");
|
||||
var any = SceneObjectLookupCache.Find("Button_Music");
|
||||
if (any != null) button_Music = any.GetComponent<Button>();
|
||||
}
|
||||
}
|
||||
@@ -169,7 +169,7 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
instantiateShowLevel = () => { gNotice.error.display("功能即将下线,禁止访问"); };
|
||||
// instantiateShowLevel = () => ShowLevelPrefab();
|
||||
instantiateEmail = () => ShowEmailPrefab();
|
||||
instantiateNotice = () => { gNotice.warning.display("姝ょ増鏈鍔熻兘鏆備笉鍙敤"); };
|
||||
instantiateNotice = () => { gNotice.warning.display("此版本该功能暂不可用"); };
|
||||
// instantiateNotice = () => ShowNoticePrefab();
|
||||
navGuideAction = () => ToggleGuideDisplay();
|
||||
instantiateMarket = () => ShowStorePrefab();
|
||||
@@ -210,7 +210,7 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
UpdateSteamUserInfo();
|
||||
InitializeMailRedPot();
|
||||
|
||||
var binder = BgmUiBinder.Instance != null ? BgmUiBinder.Instance : Object.FindAnyObjectByType<BgmUiBinder>();
|
||||
var binder = BgmUiBinder.Instance != null ? BgmUiBinder.Instance : SceneObjectLookupCache.FindAny<BgmUiBinder>();
|
||||
if (binder != null && musicPicRoot != null)
|
||||
{
|
||||
binder.SetMusicRoot(musicPicRoot);
|
||||
@@ -222,7 +222,7 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
// Try to find existing one in scene first
|
||||
if (settingsInstance == null)
|
||||
{
|
||||
var existing = GameObject.Find(settings_prefab.name + "(Clone)");
|
||||
var existing = SceneObjectLookupCache.Find(settings_prefab.name + "(Clone)");
|
||||
if (existing != null)
|
||||
{
|
||||
settingsInstance = existing;
|
||||
@@ -267,7 +267,7 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
{
|
||||
if (userInfoInstance == null)
|
||||
{
|
||||
var existing = GameObject.Find(userInfo_prefab.name + "(Clone)");
|
||||
var existing = SceneObjectLookupCache.Find(userInfo_prefab.name + "(Clone)");
|
||||
if (existing != null)
|
||||
{
|
||||
userInfoInstance = existing;
|
||||
@@ -339,7 +339,7 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
|
||||
private void ToggleMusicPic()
|
||||
{
|
||||
var binder = BgmUiBinder.Instance != null ? BgmUiBinder.Instance : Object.FindAnyObjectByType<BgmUiBinder>();
|
||||
var binder = BgmUiBinder.Instance != null ? BgmUiBinder.Instance : SceneObjectLookupCache.FindAny<BgmUiBinder>();
|
||||
if (binder != null)
|
||||
{
|
||||
binder.ToggleMusicPic();
|
||||
@@ -361,7 +361,7 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
musicPicRoot = child as RectTransform;
|
||||
return;
|
||||
}
|
||||
var sceneMusic = GameObject.Find("MusicPic");
|
||||
var sceneMusic = SceneObjectLookupCache.Find("MusicPic");
|
||||
if (sceneMusic != null)
|
||||
{
|
||||
musicPicRoot = sceneMusic.GetComponent<RectTransform>();
|
||||
@@ -393,7 +393,7 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
private void ToggleMusicPicLocal()
|
||||
{
|
||||
EnsureMusicPicRoot();
|
||||
var binder = BgmUiBinder.Instance != null ? BgmUiBinder.Instance : Object.FindAnyObjectByType<BgmUiBinder>();
|
||||
var binder = BgmUiBinder.Instance != null ? BgmUiBinder.Instance : SceneObjectLookupCache.FindAny<BgmUiBinder>();
|
||||
if (musicPicRoot == null)
|
||||
{
|
||||
if (binder != null)
|
||||
@@ -461,6 +461,8 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
|
||||
GameObject FindByName(string name)
|
||||
{
|
||||
var cached = SceneObjectLookupCache.Find(name);
|
||||
if (cached != null) return cached;
|
||||
var all = Resources.FindObjectsOfTypeAll<Transform>();
|
||||
for (int i = 0; i < all.Length; i++)
|
||||
{
|
||||
@@ -825,6 +827,15 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
EnsureSettingsLastSibling();
|
||||
BroadcastSettingsVisibility(true);
|
||||
BroadcastOverlayPanelsVisibility();
|
||||
RegisterManagedPanel(settingsInstance, () =>
|
||||
{
|
||||
if (settingsInstance != null)
|
||||
{
|
||||
settingsInstance.SetActive(false);
|
||||
BroadcastSettingsVisibility(false);
|
||||
BroadcastOverlayPanelsVisibility();
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -838,6 +849,15 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
if (settingsInstance.activeSelf)
|
||||
{
|
||||
EnsureSettingsLastSibling();
|
||||
RegisterManagedPanel(settingsInstance, () =>
|
||||
{
|
||||
if (settingsInstance != null)
|
||||
{
|
||||
settingsInstance.SetActive(false);
|
||||
BroadcastSettingsVisibility(false);
|
||||
BroadcastOverlayPanelsVisibility();
|
||||
}
|
||||
});
|
||||
}
|
||||
BroadcastSettingsVisibility(settingsInstance.activeSelf);
|
||||
BroadcastOverlayPanelsVisibility();
|
||||
@@ -859,6 +879,14 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
PlacePanelBelowSettings(userInfoInstance);
|
||||
userInfoInstance.SetActive(true);
|
||||
BroadcastOverlayPanelsVisibility();
|
||||
RegisterManagedPanel(userInfoInstance, () =>
|
||||
{
|
||||
if (userInfoInstance != null)
|
||||
{
|
||||
userInfoInstance.SetActive(false);
|
||||
BroadcastOverlayPanelsVisibility();
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -867,6 +895,14 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
if (userInfoInstance.activeSelf)
|
||||
{
|
||||
PlacePanelBelowSettings(userInfoInstance);
|
||||
RegisterManagedPanel(userInfoInstance, () =>
|
||||
{
|
||||
if (userInfoInstance != null)
|
||||
{
|
||||
userInfoInstance.SetActive(false);
|
||||
BroadcastOverlayPanelsVisibility();
|
||||
}
|
||||
});
|
||||
}
|
||||
BroadcastOverlayPanelsVisibility();
|
||||
}
|
||||
@@ -910,6 +946,23 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
GlobalOverlayPanelVisibilityChanged?.Invoke(visible);
|
||||
}
|
||||
|
||||
private void RegisterManagedPanel(GameObject panel, System.Action closeAction)
|
||||
{
|
||||
if (panel == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UIBackStack.RegisterOrBump(
|
||||
panel,
|
||||
() => panel != null && panel.activeInHierarchy,
|
||||
() =>
|
||||
{
|
||||
closeAction?.Invoke();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
private void ShowLevelPrefab()
|
||||
{
|
||||
if (ToggleIfAlreadyOpen(ref showLevelInstance))
|
||||
@@ -920,6 +973,7 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
if (OpenPrefab(showLevel_prefab, ref showLevelInstance))
|
||||
{
|
||||
CloseInfoPanels(showLevelInstance);
|
||||
RegisterManagedPanel(showLevelInstance, () => CloseManagedOverlay(showLevelInstance));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -933,6 +987,7 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
if (OpenPrefab(store_prefab, ref storeInstance))
|
||||
{
|
||||
CloseInfoPanels(storeInstance);
|
||||
RegisterManagedPanel(storeInstance, () => CloseManagedOverlay(storeInstance));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -946,6 +1001,7 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
if (OpenPrefab(email_prefab, ref emailInstance))
|
||||
{
|
||||
CloseInfoPanels(emailInstance);
|
||||
RegisterManagedPanel(emailInstance, () => CloseManagedOverlay(emailInstance));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -959,6 +1015,7 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
if (OpenPrefab(notice_prefab, ref noticeInstance))
|
||||
{
|
||||
CloseInfoPanels(noticeInstance);
|
||||
RegisterManagedPanel(noticeInstance, () => CloseManagedOverlay(noticeInstance));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -972,9 +1029,21 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
if (OpenPrefab(userBag_prefab, ref userBagInstance))
|
||||
{
|
||||
CloseInfoPanels(userBagInstance);
|
||||
RegisterManagedPanel(userBagInstance, () => CloseManagedOverlay(userBagInstance));
|
||||
}
|
||||
}
|
||||
|
||||
private void CloseManagedOverlay(GameObject instance)
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
instance.SetActive(false);
|
||||
BroadcastOverlayPanelsVisibility();
|
||||
}
|
||||
|
||||
private bool ToggleIfAlreadyOpen(ref GameObject instance)
|
||||
{
|
||||
if (instance == null)
|
||||
@@ -1089,7 +1158,7 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
}
|
||||
}
|
||||
|
||||
GameObject existing = GameObject.Find(prefab.name + "(Clone)");
|
||||
GameObject existing = SceneObjectLookupCache.Find(prefab.name + "(Clone)");
|
||||
return existing;
|
||||
}
|
||||
|
||||
@@ -1262,6 +1331,11 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
if (navSceneLoading) return;
|
||||
InitializeSceneHistoryIfNeeded();
|
||||
|
||||
if (UIBackStack.TryHandleTop())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string current = SceneManager.GetActiveScene().name ?? string.Empty;
|
||||
string target = null;
|
||||
|
||||
@@ -1330,7 +1404,7 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
{
|
||||
Debug.LogWarning("[Steam] SteamManager not initialized.");
|
||||
if (steamStatusText != null)
|
||||
steamStatusText.text = "Unknown Server";
|
||||
steamStatusText.text = LocalizationService.Get("steam.status.unknown", "Unknown Server");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1342,7 +1416,7 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
steamUserNameText.text = SteamFriends.GetPersonaName();
|
||||
|
||||
if (steamUserID64Text != null)
|
||||
steamUserID64Text.text = "Uid : " + steamID.m_SteamID.ToString();
|
||||
steamUserID64Text.text = LocalizationService.GetFormat("steam.uid_format", steamID.m_SteamID.ToString());
|
||||
|
||||
// Online status check
|
||||
EPersonaState state = SteamFriends.GetPersonaState();
|
||||
@@ -1350,7 +1424,9 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
|
||||
if (steamStatusText != null)
|
||||
{
|
||||
steamStatusText.text = isOffline ? "Steam Offline" : "Steam Online";
|
||||
steamStatusText.text = isOffline
|
||||
? LocalizationService.Get("steam.status.offline", "Steam Offline")
|
||||
: LocalizationService.Get("steam.status.online", "Steam Online");
|
||||
}
|
||||
|
||||
if (steamUserAvatarImage != null)
|
||||
@@ -1390,7 +1466,7 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
{
|
||||
Debug.LogError("[Steam] Error updating steam info: " + e);
|
||||
if (steamStatusText != null)
|
||||
steamStatusText.text = "Unknown Server";
|
||||
steamStatusText.text = LocalizationService.Get("steam.status.unknown", "Unknown Server");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public class loadtopandbottomPrefab: MonoBehaviour
|
||||
Camera cam = Camera.main;
|
||||
if (cam == null)
|
||||
{
|
||||
cam = Object.FindAnyObjectByType<Camera>();
|
||||
cam = SceneObjectLookupCache.FindAny<Camera>();
|
||||
}
|
||||
canvas.worldCamera = cam;
|
||||
cam = null;
|
||||
@@ -69,7 +69,7 @@ public class loadtopandbottomPrefab: MonoBehaviour
|
||||
{
|
||||
return;
|
||||
}
|
||||
UI_Panel_Main main = Object.FindAnyObjectByType<UI_Panel_Main>();
|
||||
UI_Panel_Main main = SceneObjectLookupCache.FindAny<UI_Panel_Main>();
|
||||
if (main == null)
|
||||
{
|
||||
return;
|
||||
|
||||
@@ -5,46 +5,36 @@ using UnityEngine.SceneManagement;
|
||||
|
||||
public class Music_Mgr : Singleton_Mono<Music_Mgr>
|
||||
{
|
||||
private const string MainSceneName = "Main_main";
|
||||
private const string GameplaySceneName = "gamePlay_gamePlay";
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
SceneManager.sceneLoaded += OnSceneLoaded;
|
||||
ApplyScenePlaybackPolicy(SceneManager.GetActiveScene());
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
SceneManager.sceneLoaded -= OnSceneLoaded;
|
||||
StopMusicPlayback();
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
{
|
||||
StopMusicPlayback();
|
||||
base.OnDestroy();
|
||||
}
|
||||
|
||||
private void OnApplicationQuit()
|
||||
{
|
||||
StopMusicPlayback();
|
||||
}
|
||||
|
||||
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
|
||||
{
|
||||
// 现在这两个场景是不合规的,需要停止播放
|
||||
bool isDisallowedScene = scene.name == "Main_main" || scene.name == "gamePlay_gamePlay";
|
||||
ApplyScenePlaybackPolicy(scene);
|
||||
|
||||
if (isDisallowedScene)
|
||||
{
|
||||
// 如果是不合规场景且正在播放,则停止
|
||||
if (AudioSource != null && AudioSource.isPlaying)
|
||||
{
|
||||
AudioSource.Stop();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 如果是合规场景(其他所有场景)且当前没在播放,则尝试播放
|
||||
if (AudioSource != null && !AudioSource.isPlaying)
|
||||
{
|
||||
if (Music_Cur != null)
|
||||
{
|
||||
AudioSource.Play();
|
||||
}
|
||||
else if (Music_Data_List != null && Music_Data_List.Count > 0)
|
||||
{
|
||||
Play(Music_Data_List[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 切换场景后,如果存在播放器UI,确保其显示正确的数据
|
||||
if (Music_Cur != null)
|
||||
{
|
||||
var players = Object.FindObjectsByType<MusicPlayer>(FindObjectsInactive.Include, FindObjectsSortMode.None);
|
||||
@@ -57,13 +47,14 @@ public class Music_Mgr : Singleton_Mono<Music_Mgr>
|
||||
|
||||
public static string Get_Time_Max(AudioClip clip)
|
||||
{
|
||||
|
||||
return Get_Time(clip == null ? 0 : (int)clip.length);
|
||||
}
|
||||
|
||||
public static string Get_Time_Cur(AudioSource aus)
|
||||
{
|
||||
return Get_Time((int)aus.time);
|
||||
}
|
||||
|
||||
private static System.Text.StringBuilder _timeSb = new System.Text.StringBuilder();
|
||||
|
||||
public static string Get_Time(int time)
|
||||
@@ -80,6 +71,7 @@ public class Music_Mgr : Singleton_Mono<Music_Mgr>
|
||||
_timeSb.Append(currentMinute.ToString("D2")).Append(":").Append(currentSecond.ToString("D2")).Append(" ");
|
||||
return _timeSb.ToString();
|
||||
}
|
||||
|
||||
public static float Get_Time_Cur_Prv(AudioSource aus)
|
||||
{
|
||||
return aus.time / aus.clip.length;
|
||||
@@ -88,12 +80,14 @@ public class Music_Mgr : Singleton_Mono<Music_Mgr>
|
||||
public List<Music_Data> Music_Data_List;
|
||||
public AudioSource AudioSource;
|
||||
public Music_Data Music_Cur;
|
||||
|
||||
protected override void In_Init()
|
||||
{
|
||||
if (TryGetComponent(out AudioSource) == false)
|
||||
{
|
||||
AudioSource = gameObject.AddComponent<AudioSource>();
|
||||
}
|
||||
|
||||
StartCoroutine(LoadMusicDataRoutine());
|
||||
}
|
||||
|
||||
@@ -105,25 +99,30 @@ public class Music_Mgr : Singleton_Mono<Music_Mgr>
|
||||
for (int i = 0; i < rawData.Length; i++)
|
||||
{
|
||||
Music_Data_List.Add(rawData[i]);
|
||||
// Avoid a frame hitch if there are many clips in Resources.
|
||||
if ((i & 7) == 7) yield return null;
|
||||
}
|
||||
|
||||
if (Music_Data_List.Count > 0)
|
||||
{
|
||||
Play(Music_Data_List[0]);
|
||||
ApplyScenePlaybackPolicy(SceneManager.GetActiveScene());
|
||||
}
|
||||
|
||||
yield break;
|
||||
}
|
||||
|
||||
public void Play(Music_Data data)
|
||||
{
|
||||
if (data == null) return;
|
||||
if (!ShouldPlayInScene(SceneManager.GetActiveScene().name))
|
||||
{
|
||||
StopMusicPlayback();
|
||||
return;
|
||||
}
|
||||
|
||||
Music_Cur = data;
|
||||
AudioSource.clip = data.Clip;
|
||||
AudioSource.Play();
|
||||
|
||||
// 刷新所有正在显示的 MusicPlayer UI
|
||||
var players = Object.FindObjectsByType<MusicPlayer>(FindObjectsInactive.Include, FindObjectsSortMode.None);
|
||||
foreach (var player in players)
|
||||
{
|
||||
@@ -146,8 +145,55 @@ public class Music_Mgr : Singleton_Mono<Music_Mgr>
|
||||
index = (index - 1 + Music_Data_List.Count) % Music_Data_List.Count;
|
||||
Play(Music_Data_List[index]);
|
||||
}
|
||||
|
||||
protected override bool Is_Singleton_Auto()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool ShouldPlayInScene(string sceneName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(sceneName))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return !string.Equals(sceneName, MainSceneName, System.StringComparison.OrdinalIgnoreCase)
|
||||
&& !string.Equals(sceneName, GameplaySceneName, System.StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
private void ApplyScenePlaybackPolicy(Scene scene)
|
||||
{
|
||||
if (!scene.IsValid() || !scene.isLoaded)
|
||||
{
|
||||
StopMusicPlayback();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ShouldPlayInScene(scene.name))
|
||||
{
|
||||
StopMusicPlayback();
|
||||
return;
|
||||
}
|
||||
|
||||
if (AudioSource != null && !AudioSource.isPlaying)
|
||||
{
|
||||
if (Music_Cur != null)
|
||||
{
|
||||
AudioSource.Play();
|
||||
}
|
||||
else if (Music_Data_List != null && Music_Data_List.Count > 0)
|
||||
{
|
||||
Play(Music_Data_List[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void StopMusicPlayback()
|
||||
{
|
||||
if (AudioSource != null && AudioSource.isPlaying)
|
||||
{
|
||||
AudioSource.Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ public class PauseManager : MonoBehaviour
|
||||
if (onlyInGameplayScene && !IsGameplaySceneActive()) allowOverlay = false;
|
||||
else if (requirePlaybackStarted)
|
||||
{
|
||||
var gm = FindAnyObjectByType<GameManager>();
|
||||
var gm = SceneObjectLookupCache.FindAny<GameManager>();
|
||||
// If GM missing or playback not started, don't show overlay yet
|
||||
if (gm != null && !gm.PlaybackStarted) allowOverlay = false;
|
||||
}
|
||||
@@ -244,7 +244,7 @@ public class PauseManager : MonoBehaviour
|
||||
if (onlyInGameplayScene && !IsGameplaySceneActive()) return false;
|
||||
if (!requirePlaybackStarted) return true;
|
||||
|
||||
var gm = FindAnyObjectByType<GameManager>();
|
||||
var gm = SceneObjectLookupCache.FindAny<GameManager>();
|
||||
if (gm == null) return false;
|
||||
|
||||
// If already paused, allow input to unpause regardless of PlaybackStarted state
|
||||
@@ -541,8 +541,8 @@ public class PauseManager : MonoBehaviour
|
||||
ShowOverlayAnimated(false);
|
||||
|
||||
// Replay 3-2-1-Go immediately on continue click.
|
||||
var gm = FindAnyObjectByType<GameManager>();
|
||||
var ready = gm != null ? gm.readyLetsGo : FindAnyObjectByType<readyLetsGo>();
|
||||
var gm = SceneObjectLookupCache.FindAny<GameManager>();
|
||||
var ready = gm != null ? gm.readyLetsGo : SceneObjectLookupCache.FindAny<readyLetsGo>();
|
||||
float originalWaitingDuration = 0f;
|
||||
bool waitingDurationOverridden = false;
|
||||
if (ready != null)
|
||||
@@ -581,7 +581,7 @@ public class PauseManager : MonoBehaviour
|
||||
Time.timeScale = 1f;
|
||||
try { OnPauseStateChanged?.Invoke(false); } catch { }
|
||||
|
||||
var bmm = FindAnyObjectByType<BeatmapManager>();
|
||||
var bmm = SceneObjectLookupCache.FindAny<BeatmapManager>();
|
||||
if (bmm != null && bmm.assignedSongData != null)
|
||||
{
|
||||
int diff = bmm.assignedDifficulty;
|
||||
@@ -630,7 +630,7 @@ public class PauseManager : MonoBehaviour
|
||||
|
||||
if (pauseTriggerButton == null)
|
||||
{
|
||||
var pauseGO = GameObject.Find(pauseButtonScenePath);
|
||||
var pauseGO = SceneObjectLookupCache.Find(pauseButtonScenePath);
|
||||
if (pauseGO == null)
|
||||
pauseGO = FindByNameInScene("Pause");
|
||||
if (pauseGO != null)
|
||||
@@ -707,7 +707,7 @@ public class PauseManager : MonoBehaviour
|
||||
return;
|
||||
}
|
||||
|
||||
var topController = FindAnyObjectByType<btmandtopController>();
|
||||
var topController = SceneObjectLookupCache.FindAny<btmandtopController>();
|
||||
if (topController != null)
|
||||
{
|
||||
topController.SendMessage("OnSettingsNavClicked", SendMessageOptions.DontRequireReceiver);
|
||||
|
||||
@@ -15,7 +15,7 @@ public abstract class Singleton_Mono<T> : MonoBehaviour, I_Singleton where T : S
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
T obj = FindFirstObjectByType<T>();
|
||||
T obj = SceneObjectLookupCache.FindFirst<T>();
|
||||
if (obj != null)
|
||||
{
|
||||
obj.TryGetComponent(out Singleton_Mono<T> s);
|
||||
|
||||
@@ -8,6 +8,13 @@ using UnityEngine.UI;
|
||||
using TMPro;
|
||||
using DG.Tweening;
|
||||
|
||||
[Serializable]
|
||||
public class UI_FunctionHoverSceneBinding
|
||||
{
|
||||
public string path;
|
||||
public RectTransform target;
|
||||
}
|
||||
|
||||
public class UI_FunctionHoverGuide : MonoBehaviour
|
||||
{
|
||||
[Header("Scene")]
|
||||
@@ -31,6 +38,7 @@ public class UI_FunctionHoverGuide : MonoBehaviour
|
||||
public RawImage functionIconRaw;
|
||||
public TMP_Text functionTextTmp;
|
||||
public Text functionTextLegacy;
|
||||
public List<UI_FunctionHoverSceneBinding> sceneBindings = new();
|
||||
|
||||
[Header("Animation")]
|
||||
public float iconStartScale = 0.6f;
|
||||
@@ -177,9 +185,9 @@ public class UI_FunctionHoverGuide : MonoBehaviour
|
||||
{
|
||||
GameObject go = null;
|
||||
if (!string.IsNullOrWhiteSpace(functionRootPath))
|
||||
go = GameObject.Find(functionRootPath);
|
||||
go = SceneObjectLookupCache.Find(functionRootPath);
|
||||
if (go == null && !string.IsNullOrWhiteSpace(targetBasePath))
|
||||
go = GameObject.Find(CombinePath(targetBasePath, functionRootName));
|
||||
go = SceneObjectLookupCache.Find(CombinePath(targetBasePath, functionRootName));
|
||||
if (go == null)
|
||||
go = FindByNameContains(functionRootName);
|
||||
if (go != null)
|
||||
@@ -190,12 +198,12 @@ public class UI_FunctionHoverGuide : MonoBehaviour
|
||||
|
||||
if (functionIcon == null)
|
||||
{
|
||||
var icon = FindChildGraphic(functionRoot, iconNameContains);
|
||||
var icon = FindChildGraphic(functionRoot, "ICON");
|
||||
if (icon != null) functionIcon = icon;
|
||||
}
|
||||
if (functionIconRaw == null && functionIcon == null)
|
||||
{
|
||||
var raw = FindChildRawImage(functionRoot, iconNameContains);
|
||||
var raw = FindChildRawImage(functionRoot, "ICON");
|
||||
if (raw != null) functionIconRaw = raw;
|
||||
}
|
||||
|
||||
@@ -268,16 +276,31 @@ public class UI_FunctionHoverGuide : MonoBehaviour
|
||||
{
|
||||
var entry = config.entries[i];
|
||||
if (entry == null || string.IsNullOrWhiteSpace(entry.path)) continue;
|
||||
var target = FindByPath(entry.path);
|
||||
if (target == null)
|
||||
int entryWired = 0;
|
||||
var explicitTargets = FindExplicitTargets(entry.path);
|
||||
for (int t = 0; t < explicitTargets.Count; t++)
|
||||
{
|
||||
if (debugLogs)
|
||||
Debug.LogWarning("UI_FunctionHoverGuide: target not found for path: " + entry.path);
|
||||
continue;
|
||||
var explicitTarget = explicitTargets[t];
|
||||
if (explicitTarget == null) continue;
|
||||
if (AttachHoverTargets(explicitTarget.transform, entry))
|
||||
entryWired++;
|
||||
}
|
||||
|
||||
if (AttachHoverTargets(target.transform, entry))
|
||||
wired++;
|
||||
if (entryWired <= 0)
|
||||
{
|
||||
var target = FindByPath(entry.path);
|
||||
if (target == null)
|
||||
{
|
||||
if (debugLogs)
|
||||
Debug.LogWarning("UI_FunctionHoverGuide: target not found for path: " + entry.path);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (AttachHoverTargets(target.transform, entry))
|
||||
entryWired++;
|
||||
}
|
||||
|
||||
wired += entryWired;
|
||||
}
|
||||
return wired;
|
||||
}
|
||||
@@ -393,12 +416,12 @@ public class UI_FunctionHoverGuide : MonoBehaviour
|
||||
private GameObject FindByPath(string path)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(path)) return null;
|
||||
var go = GameObject.Find(path);
|
||||
var go = SceneObjectLookupCache.Find(path);
|
||||
if (go != null) return go;
|
||||
if (!string.IsNullOrWhiteSpace(targetBasePath))
|
||||
{
|
||||
var combined = CombinePath(targetBasePath, path);
|
||||
go = GameObject.Find(combined);
|
||||
go = SceneObjectLookupCache.Find(combined);
|
||||
if (go != null) return go;
|
||||
}
|
||||
|
||||
@@ -422,9 +445,33 @@ public class UI_FunctionHoverGuide : MonoBehaviour
|
||||
return FindByNameContains(last);
|
||||
}
|
||||
|
||||
private List<GameObject> FindExplicitTargets(string path)
|
||||
{
|
||||
var result = new List<GameObject>();
|
||||
if (sceneBindings == null || sceneBindings.Count == 0 || string.IsNullOrWhiteSpace(path))
|
||||
return result;
|
||||
|
||||
string normalizedTarget = NormalizePath(path);
|
||||
for (int i = 0; i < sceneBindings.Count; i++)
|
||||
{
|
||||
var binding = sceneBindings[i];
|
||||
if (binding == null || binding.target == null || string.IsNullOrWhiteSpace(binding.path))
|
||||
continue;
|
||||
|
||||
if (!string.Equals(NormalizePath(binding.path), normalizedTarget, StringComparison.OrdinalIgnoreCase))
|
||||
continue;
|
||||
|
||||
result.Add(binding.target.gameObject);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private GameObject FindByNameContains(string name)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(name)) return null;
|
||||
var exact = SceneObjectLookupCache.Find(name);
|
||||
if (exact != null) return exact;
|
||||
var all = Resources.FindObjectsOfTypeAll<Transform>();
|
||||
string target = name.Replace(" ", "");
|
||||
for (int i = 0; i < all.Length; i++)
|
||||
@@ -470,48 +517,47 @@ public class UI_FunctionHoverGuide : MonoBehaviour
|
||||
return string.Join("/", parts);
|
||||
}
|
||||
|
||||
private static Image FindChildGraphic(Transform root, string nameContains)
|
||||
private static Image FindChildGraphic(Transform root, string exactName)
|
||||
{
|
||||
var imgs = root.GetComponentsInChildren<Image>(true);
|
||||
if (imgs == null || imgs.Length == 0) return null;
|
||||
if (!string.IsNullOrEmpty(nameContains))
|
||||
{
|
||||
string target = nameContains.Replace(" ", "");
|
||||
for (int i = 0; i < imgs.Length; i++)
|
||||
{
|
||||
var img = imgs[i];
|
||||
if (img == null) continue;
|
||||
string n = img.name.Replace(" ", "");
|
||||
if (n.IndexOf(target, StringComparison.OrdinalIgnoreCase) >= 0)
|
||||
return img;
|
||||
}
|
||||
}
|
||||
return imgs[0];
|
||||
return FindChildGraphicExact(imgs, exactName);
|
||||
}
|
||||
|
||||
private static RawImage FindChildRawImage(Transform root, string nameContains)
|
||||
private static Image FindChildGraphicExact(Image[] imgs, string exactName)
|
||||
{
|
||||
if (imgs == null || string.IsNullOrWhiteSpace(exactName)) return null;
|
||||
for (int i = 0; i < imgs.Length; i++)
|
||||
{
|
||||
var img = imgs[i];
|
||||
if (img == null) continue;
|
||||
if (string.Equals(img.name, exactName, StringComparison.OrdinalIgnoreCase))
|
||||
return img;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static RawImage FindChildRawImage(Transform root, string exactName)
|
||||
{
|
||||
var raws = root.GetComponentsInChildren<RawImage>(true);
|
||||
if (raws == null || raws.Length == 0) return null;
|
||||
if (!string.IsNullOrEmpty(nameContains))
|
||||
if (string.IsNullOrWhiteSpace(exactName)) return null;
|
||||
for (int i = 0; i < raws.Length; i++)
|
||||
{
|
||||
string target = nameContains.Replace(" ", "");
|
||||
for (int i = 0; i < raws.Length; i++)
|
||||
{
|
||||
var img = raws[i];
|
||||
if (img == null) continue;
|
||||
string n = img.name.Replace(" ", "");
|
||||
if (n.IndexOf(target, StringComparison.OrdinalIgnoreCase) >= 0)
|
||||
return img;
|
||||
}
|
||||
var raw = raws[i];
|
||||
if (raw == null) continue;
|
||||
if (string.Equals(raw.name, exactName, StringComparison.OrdinalIgnoreCase))
|
||||
return raw;
|
||||
}
|
||||
return raws[0];
|
||||
return null;
|
||||
}
|
||||
|
||||
private static TMP_Text FindChildTmp(Transform root, string nameContains)
|
||||
{
|
||||
var tmps = root.GetComponentsInChildren<TMP_Text>(true);
|
||||
if (tmps == null || tmps.Length == 0) return null;
|
||||
var exact = FindChildTmpExact(tmps, "TEXT");
|
||||
if (exact != null) return exact;
|
||||
if (!string.IsNullOrEmpty(nameContains))
|
||||
{
|
||||
string target = nameContains.Replace(" ", "");
|
||||
@@ -527,10 +573,25 @@ public class UI_FunctionHoverGuide : MonoBehaviour
|
||||
return tmps[0];
|
||||
}
|
||||
|
||||
private static TMP_Text FindChildTmpExact(TMP_Text[] tmps, string exactName)
|
||||
{
|
||||
if (tmps == null || string.IsNullOrWhiteSpace(exactName)) return null;
|
||||
for (int i = 0; i < tmps.Length; i++)
|
||||
{
|
||||
var tmp = tmps[i];
|
||||
if (tmp == null) continue;
|
||||
if (string.Equals(tmp.name, exactName, StringComparison.OrdinalIgnoreCase))
|
||||
return tmp;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Text FindChildLegacyText(Transform root, string nameContains)
|
||||
{
|
||||
var texts = root.GetComponentsInChildren<Text>(true);
|
||||
if (texts == null || texts.Length == 0) return null;
|
||||
var exact = FindChildLegacyTextExact(texts, "TEXT");
|
||||
if (exact != null) return exact;
|
||||
if (!string.IsNullOrEmpty(nameContains))
|
||||
{
|
||||
string target = nameContains.Replace(" ", "");
|
||||
@@ -546,6 +607,19 @@ public class UI_FunctionHoverGuide : MonoBehaviour
|
||||
return texts[0];
|
||||
}
|
||||
|
||||
private static Text FindChildLegacyTextExact(Text[] texts, string exactName)
|
||||
{
|
||||
if (texts == null || string.IsNullOrWhiteSpace(exactName)) return null;
|
||||
for (int i = 0; i < texts.Length; i++)
|
||||
{
|
||||
var text = texts[i];
|
||||
if (text == null) continue;
|
||||
if (string.Equals(text.name, exactName, StringComparison.OrdinalIgnoreCase))
|
||||
return text;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void EnsureRaycastTarget(GameObject go)
|
||||
{
|
||||
var graphics = go.GetComponentsInChildren<Graphic>(true);
|
||||
@@ -656,10 +730,8 @@ public class UI_FunctionHoverGuide : MonoBehaviour
|
||||
{
|
||||
if (!scene.IsValid()) return;
|
||||
if (scene.name.IndexOf("UI_UI", StringComparison.OrdinalIgnoreCase) < 0) return;
|
||||
if (UnityEngine.Object.FindAnyObjectByType<UI_FunctionHoverGuide>() != null) return;
|
||||
if (SceneObjectLookupCache.FindAny<UI_FunctionHoverGuide>() != null) return;
|
||||
var go = new GameObject("UI_FunctionHoverGuide");
|
||||
go.AddComponent<UI_FunctionHoverGuide>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -261,13 +261,13 @@ static class UI_UnimplementedFeatureBlockerBootstrap
|
||||
{
|
||||
if (!UI_UnimplementedFeatureBlocker.RuntimeEnabled)
|
||||
{
|
||||
GameObject old = GameObject.Find("__UnimplementedFeatureBlockerHost");
|
||||
GameObject old = SceneObjectLookupCache.Find("__UnimplementedFeatureBlockerHost");
|
||||
if (old != null)
|
||||
UnityEngine.Object.Destroy(old);
|
||||
return;
|
||||
}
|
||||
|
||||
GameObject host = GameObject.Find("__UnimplementedFeatureBlockerHost");
|
||||
GameObject host = SceneObjectLookupCache.Find("__UnimplementedFeatureBlockerHost");
|
||||
if (host == null)
|
||||
host = new GameObject("__UnimplementedFeatureBlockerHost");
|
||||
UnityEngine.Object.DontDestroyOnLoad(host);
|
||||
|
||||
@@ -38,7 +38,7 @@ public class UnimplementedFeaturePrompt : MonoBehaviour
|
||||
if (instance != null)
|
||||
return;
|
||||
|
||||
GameObject host = GameObject.Find("__UnimplementedFeaturePromptHost");
|
||||
GameObject host = SceneObjectLookupCache.Find("__UnimplementedFeaturePromptHost");
|
||||
if (host == null)
|
||||
{
|
||||
host = new GameObject("__UnimplementedFeaturePromptHost");
|
||||
|
||||
Reference in New Issue
Block a user