1.全阶段异步加载与AB包预加载2.node加载无效的问题依然存在
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user