1.全阶段异步加载与AB包预加载2.node加载无效的问题依然存在

This commit is contained in:
2025-10-06 16:09:52 +08:00
parent 8f8dfcbb64
commit 334f55a250
27 changed files with 1274 additions and 1220 deletions

View File

@@ -12,18 +12,10 @@ namespace Demo.Game
return new GameObject().AddComponent<ParticleJudgement>();
}
private List<IEnumerator> AssetBundleLoadings = new();
[Content, SerializeField] private Dictionary<IInteraction.JudgementLevel, string> AssetBundles = new();
[Content, SerializeField] private Dictionary<IInteraction.JudgementLevel, GameObject> Prefabs = new();
[Content, SerializeField] private Dictionary<IInteraction.JudgementLevel, float> Durations = new();
public override IEnumerator LoadScript(string script)
{
yield return base.LoadScript(script);
foreach (var loading in AssetBundleLoadings)
yield return loading;
}
public override IEnumerator UnloadScript()
{
yield return base.UnloadScript();
@@ -47,26 +39,20 @@ namespace Demo.Game
<param name=""prefab""></param>
<param name=""duration"">判定效果会现形的持续时间</param>
")]
public void Load(string level, string ab, string prefab, string duration)
public IEnumerator Load(string level, string ab, string prefab, string duration)
{
var levelId = (IInteraction.JudgementLevel)int.Parse(level);
IEnumerator Foo()
{
AssetBundle assetBundle = null;
var ir = this.LoadAssetBundle(ab, x => assetBundle = x);
yield return ir;
var req = assetBundle.LoadAssetAsync<GameObject>(prefab);
yield return req;
GameObject sub = Instantiate(req.asset as GameObject);
sub.SetActive(false);
Prefabs.Add(levelId, sub);
sub.transform.SetParent(transform);
AssetBundles.Add(levelId, ab);
Durations.Add(levelId, float.Parse(duration));
}
AssetBundleLoadings.Add(Foo());
AssetBundle assetBundle = null;
yield return this.LoadAssetBundle(ab, x => assetBundle = x);
var req = assetBundle.LoadAssetAsync<GameObject>(prefab);
yield return req;
GameObject sub = Instantiate(req.asset as GameObject);
sub.SetActive(false);
Prefabs.Add(levelId, sub);
sub.transform.SetParent(transform);
AssetBundles.Add(levelId, ab);
Durations.Add(levelId, float.Parse(duration));
}
private void CreateParticle(GameObject prefab)