优化加载Apply
This commit is contained in:
@@ -221,17 +221,17 @@ namespace Demo.Game
|
|||||||
rootGameObject.SetContent(nameof(IsAutoPlay), IsAutoPlay ? 1 : 0);
|
rootGameObject.SetContent(nameof(IsAutoPlay), IsAutoPlay ? 1 : 0);
|
||||||
rootGameObject.SetContent("SongLength", MainAudio.CurrentClip.length);
|
rootGameObject.SetContent("SongLength", MainAudio.CurrentClip.length);
|
||||||
yield return rootGameObject.ParseScript2Expr(rootObject.LoadAsText());
|
yield return rootGameObject.ParseScript2Expr(rootObject.LoadAsText());
|
||||||
yield return rootGameObject.ApplyScript();
|
static void NDFS(ScriptableObject current)
|
||||||
IEnumerator NDFS(ScriptableObject current)
|
|
||||||
{
|
{
|
||||||
foreach (var child in current.Childs)
|
foreach (var child in current.Childs)
|
||||||
{
|
{
|
||||||
yield return NDFS(child);
|
NDFS(child);
|
||||||
}
|
}
|
||||||
if (current.IsScriptApply == false)
|
if (current.IsScriptApply == false)
|
||||||
yield return current.ApplyScript();
|
ConventionUtility.StartCoroutine(current.ApplyScript());
|
||||||
}
|
}
|
||||||
yield return NDFS(rootGameObject);
|
//yield return
|
||||||
|
NDFS(rootGameObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
|||||||
@@ -12,10 +12,18 @@ namespace Demo.Game
|
|||||||
return new GameObject().AddComponent<ParticleJudgement>();
|
return new GameObject().AddComponent<ParticleJudgement>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Content, SerializeField] private List<IEnumerator> TaskLoader = new();
|
||||||
[Content, SerializeField] private Dictionary<IInteraction.JudgementLevel, string> AssetBundles = 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, GameObject> Prefabs = new();
|
||||||
[Content, SerializeField] private Dictionary<IInteraction.JudgementLevel, float> Durations = new();
|
[Content, SerializeField] private Dictionary<IInteraction.JudgementLevel, float> Durations = new();
|
||||||
|
|
||||||
|
protected override IEnumerator DoSomethingDuringApplyScript()
|
||||||
|
{
|
||||||
|
yield return base.DoSomethingDuringApplyScript();
|
||||||
|
foreach (var task in TaskLoader)
|
||||||
|
yield return task;
|
||||||
|
}
|
||||||
|
|
||||||
public override IEnumerator UnloadScript()
|
public override IEnumerator UnloadScript()
|
||||||
{
|
{
|
||||||
yield return base.UnloadScript();
|
yield return base.UnloadScript();
|
||||||
@@ -31,18 +39,18 @@ namespace Demo.Game
|
|||||||
/// <param name="prefab"></param>
|
/// <param name="prefab"></param>
|
||||||
/// <param name="duration">判定效果会现形的持续时间</param>
|
/// <param name="duration">判定效果会现形的持续时间</param>
|
||||||
[Convention.RScript.Variable.Attr.Method]
|
[Convention.RScript.Variable.Attr.Method]
|
||||||
public IEnumerator Load(IInteraction.JudgementLevel levelId, string ab, string prefab, float duration)
|
public void Load(IInteraction.JudgementLevel levelId, string ab, string prefab, float duration)
|
||||||
{
|
{
|
||||||
AssetBundle assetBundle = null;
|
TaskLoader.Add(this.LoadAssetBundle(ab, assetBundle =>
|
||||||
yield return this.LoadAssetBundle(ab, x => assetBundle = x);
|
{
|
||||||
var req = assetBundle.LoadAssetAsync<GameObject>(prefab);
|
var obj = assetBundle.LoadAsset<GameObject>(prefab);
|
||||||
yield return req;
|
GameObject sub = Instantiate(obj);
|
||||||
GameObject sub = Instantiate(req.asset as GameObject);
|
sub.SetActive(false);
|
||||||
sub.SetActive(false);
|
Prefabs.Add(levelId, sub);
|
||||||
Prefabs.Add(levelId, sub);
|
sub.transform.SetParent(transform);
|
||||||
sub.transform.SetParent(transform);
|
AssetBundles.Add(levelId, ab);
|
||||||
AssetBundles.Add(levelId, ab);
|
Durations.Add(levelId, duration);
|
||||||
Durations.Add(levelId, duration);
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreateParticle(GameObject prefab)
|
private void CreateParticle(GameObject prefab)
|
||||||
|
|||||||
Reference in New Issue
Block a user