ParticleEffect出现无法加载完成的异常

This commit is contained in:
2025-11-30 17:33:26 +08:00
parent 0b80d0a775
commit 430209c948
5 changed files with 66 additions and 45 deletions

View File

@@ -1,5 +1,7 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Convention;
using UnityEngine;
namespace Demo.Game
@@ -11,9 +13,17 @@ namespace Demo.Game
return new GameObject().AddComponent<ParticleEffect>();
}
private Dictionary<string,bool> AssetBundleLoaders = new();
private readonly List<string> AssetBundles = new();
private readonly List<GameObject> Prefabs = new();
protected override IEnumerator DoSomethingDuringApplyScript()
{
yield return base.DoSomethingDuringApplyScript();
while (AssetBundleLoaders.Any(x => x.Value == false))
yield return null;
}
public override IEnumerator UnloadScript()
{
yield return base.UnloadScript();
@@ -29,9 +39,10 @@ namespace Demo.Game
/// <param name="ab"></param>
/// <param name="prefab"></param>
[Convention.RScript.Variable.Attr.Method]
public IEnumerator Load(string ab, string prefab)
public void Load(string ab, string prefab)
{
yield return this.LoadAssetBundle(ab, x =>
AssetBundleLoaders.TryAdd(ab, false);
ConventionUtility.StartCoroutine(this.LoadAssetBundle(ab, x =>
{
GameObject sub = Instantiate(x.LoadAsset<GameObject>(prefab));
sub.SetActive(false);
@@ -39,7 +50,8 @@ namespace Demo.Game
sub.transform.SetParent(transform);
sub.transform.localPosition = Vector3.zero;
AssetBundles.Add(ab);
});
AssetBundleLoaders[ab] = true;
}));
}
public override void OnInit()

View File

@@ -116,9 +116,9 @@ namespace Demo.Game
/// </summary>
/// <param name="path"></param>
[Convention.RScript.Variable.Attr.Method]
public void Bind(string path)
public void Bind(IInteraction target)
{
MyInteractionModule = FindWithPath(path) as IInteraction;
MyInteractionModule = target;
}
/// <summary>