From 8d8722604524e5eaaf92753949d6d4c7800ea8ee Mon Sep 17 00:00:00 2001 From: yyl <yyl> Date: 星期二, 16 九月 2025 14:32:10 +0800 Subject: [PATCH] 125 特效持续播放问题解决 --- Main/Component/UI/Effect/BattleEffectPlayer.cs | 47 ++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 40 insertions(+), 7 deletions(-) diff --git a/Main/Component/UI/Effect/BattleEffectPlayer.cs b/Main/Component/UI/Effect/BattleEffectPlayer.cs index f9f4f4e..703ed32 100644 --- a/Main/Component/UI/Effect/BattleEffectPlayer.cs +++ b/Main/Component/UI/Effect/BattleEffectPlayer.cs @@ -66,6 +66,10 @@ public Action onComplete; + private bool isPlaying = false; + + private float timer = 0f; + protected virtual void OnEnable() { if (spineComp != null) @@ -212,15 +216,34 @@ this.gameObject.SetActive(true); } - if (effectConfig.autoDestroy != 0) - { - GameObject.Destroy(gameObject, effectConfig.destroyDelay / speedRate); - } - + isPlaying = true; + timer = 0f; PlayEffect(); + } + + public void Run() + { + if (null == effectConfig) + { + return; + } + + if (!isPlaying) + { + return; + } + + if (effectConfig.autoDestroy != 0) + { + timer += Time.deltaTime * speedRate; + if (timer >= effectConfig.destroyDelay) + { + GameObject.DestroyImmediate(gameObject); + } + } } protected virtual void PlayEffect() @@ -451,7 +474,7 @@ public void Pause() { - if (effectTarget == null) return; + // if (effectTarget == null) return; // Spine鍔ㄧ敾 // var spineGraphics = effectTarget.GetComponentsInChildren<SkeletonGraphic>(true); @@ -459,6 +482,11 @@ if (spineComp != null) { spineComp.timeScale = 0f; + } + + if (spineAnimationState != null) + { + spineAnimationState.TimeScale = 0f; } // Animator鍔ㄧ敾 @@ -476,13 +504,18 @@ public void Resume() { - if (effectTarget == null) return; + // if (effectTarget == null) return; if (spineComp != null) { spineComp.timeScale = speedRate; } + if (spineAnimationState != null) + { + spineAnimationState.TimeScale = speedRate; + } + // Animator鍔ㄧ敾 foreach (var animator in animatorList) { -- Gitblit v1.8.0