技能主要更新,修复卡顿并加入动画,以及各种其他更新。
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public static class BgmRuntimeBootstrap
|
||||
{
|
||||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)]
|
||||
private static void Bootstrap()
|
||||
{
|
||||
var mgr = BgmPlaybackManager.EnsureInstance();
|
||||
mgr.EnsurePlaying();
|
||||
|
||||
// Ensure UI binder exists
|
||||
if (Object.FindAnyObjectByType<BgmUiBinder>() == null)
|
||||
{
|
||||
var go = new GameObject("BGM_UI_Binder");
|
||||
go.AddComponent<BgmUiBinder>();
|
||||
Object.DontDestroyOnLoad(go);
|
||||
}
|
||||
|
||||
RemoveBgmParticlesInLoadedScenes();
|
||||
SceneManager.sceneLoaded -= OnSceneLoaded;
|
||||
SceneManager.sceneLoaded += OnSceneLoaded;
|
||||
}
|
||||
|
||||
private static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
|
||||
{
|
||||
RemoveBgmParticlesInLoadedScenes();
|
||||
}
|
||||
|
||||
private static void RemoveBgmParticlesInLoadedScenes()
|
||||
{
|
||||
var emitters = Object.FindObjectsByType<BgmParticleEmitter>(FindObjectsInactive.Include, FindObjectsSortMode.None);
|
||||
for (int i = 0; i < emitters.Length; i++)
|
||||
{
|
||||
var e = emitters[i];
|
||||
if (e == null) continue;
|
||||
if (!e.gameObject.scene.IsValid() || !e.gameObject.scene.isLoaded) continue;
|
||||
Object.Destroy(e.gameObject);
|
||||
}
|
||||
|
||||
var all = Resources.FindObjectsOfTypeAll<Transform>();
|
||||
for (int i = 0; i < all.Length; i++)
|
||||
{
|
||||
var t = all[i];
|
||||
if (t == null) continue;
|
||||
if (!t.gameObject.scene.IsValid() || !t.gameObject.scene.isLoaded) continue;
|
||||
if (t.name.Equals("BgmParticles", System.StringComparison.OrdinalIgnoreCase))
|
||||
Object.Destroy(t.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user