From 11623b044b514f6fee7f8439bea0234c40af9b47 Mon Sep 17 00:00:00 2001 From: ninemine <1371605831@qq.com> Date: Tue, 2 Dec 2025 16:39:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8A=A0=E8=BD=BDApply?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Framework/GameContent/GameController.cs | 10 +++---- .../JudgementEffect/ParticleJudgement.cs | 30 ++++++++++++------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/Assets/Scripts/Framework/GameContent/GameController.cs b/Assets/Scripts/Framework/GameContent/GameController.cs index 9428b27..6e2d476 100644 --- a/Assets/Scripts/Framework/GameContent/GameController.cs +++ b/Assets/Scripts/Framework/GameContent/GameController.cs @@ -221,17 +221,17 @@ namespace Demo.Game rootGameObject.SetContent(nameof(IsAutoPlay), IsAutoPlay ? 1 : 0); rootGameObject.SetContent("SongLength", MainAudio.CurrentClip.length); yield return rootGameObject.ParseScript2Expr(rootObject.LoadAsText()); - yield return rootGameObject.ApplyScript(); - IEnumerator NDFS(ScriptableObject current) + static void NDFS(ScriptableObject current) { foreach (var child in current.Childs) { - yield return NDFS(child); + NDFS(child); } if (current.IsScriptApply == false) - yield return current.ApplyScript(); + ConventionUtility.StartCoroutine(current.ApplyScript()); } - yield return NDFS(rootGameObject); + //yield return + NDFS(rootGameObject); } } finally diff --git a/Assets/Scripts/Interaction/JudgementEffect/ParticleJudgement.cs b/Assets/Scripts/Interaction/JudgementEffect/ParticleJudgement.cs index b23329b..7177b81 100644 --- a/Assets/Scripts/Interaction/JudgementEffect/ParticleJudgement.cs +++ b/Assets/Scripts/Interaction/JudgementEffect/ParticleJudgement.cs @@ -12,10 +12,18 @@ namespace Demo.Game return new GameObject().AddComponent(); } + [Content, SerializeField] private List TaskLoader = new(); [Content, SerializeField] private Dictionary AssetBundles = new(); [Content, SerializeField] private Dictionary Prefabs = new(); [Content, SerializeField] private Dictionary Durations = new(); + protected override IEnumerator DoSomethingDuringApplyScript() + { + yield return base.DoSomethingDuringApplyScript(); + foreach (var task in TaskLoader) + yield return task; + } + public override IEnumerator UnloadScript() { yield return base.UnloadScript(); @@ -31,18 +39,18 @@ namespace Demo.Game /// /// 判定效果会现形的持续时间 [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; - yield return this.LoadAssetBundle(ab, x => assetBundle = x); - var req = assetBundle.LoadAssetAsync(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, duration); + TaskLoader.Add(this.LoadAssetBundle(ab, assetBundle => + { + var obj = assetBundle.LoadAsset(prefab); + GameObject sub = Instantiate(obj); + sub.SetActive(false); + Prefabs.Add(levelId, sub); + sub.transform.SetParent(transform); + AssetBundles.Add(levelId, ab); + Durations.Add(levelId, duration); + })); } private void CreateParticle(GameObject prefab)