| | |
| | | |
| | | public Action onComplete; |
| | | |
| | | private bool isPlaying = false; |
| | | |
| | | private float timer = 0f; |
| | | |
| | | protected virtual void OnEnable() |
| | | { |
| | | if (spineComp != null) |
| | |
| | | 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() |
| | |
| | | |
| | | public void Pause() |
| | | { |
| | | if (effectTarget == null) return; |
| | | // if (effectTarget == null) return; |
| | | |
| | | // Spine动画 |
| | | // var spineGraphics = effectTarget.GetComponentsInChildren<SkeletonGraphic>(true); |
| | |
| | | if (spineComp != null) |
| | | { |
| | | spineComp.timeScale = 0f; |
| | | } |
| | | |
| | | if (spineAnimationState != null) |
| | | { |
| | | spineAnimationState.TimeScale = 0f; |
| | | } |
| | | |
| | | // Animator动画 |
| | |
| | | |
| | | 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) |
| | | { |