ParticleEffect出现无法加载完成的异常
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user