protected virtual IEnumerator AnimationEventsProcessing() { string clipName = "None"; string lastClipName = "None"; float startTime = 0; float clipLength = 0; bool loopReady = false; int xCount = 0; AnimationEventProperty.EventProperty[] eventProperty = null; ShakeCamera shakeCamera = ShakeCamera.Instance; while (true) { if (animator.GetCurrentAnimatorClipInfoCount(0) > 0) { AnimatorClipInfo clipInfo = animator.GetCurrentAnimatorClipInfo(0)[0]; clipName = clipInfo.clip.name; clipLength = clipInfo.clip.length; } if (clipName != lastClipName) { for (int i = 0, length = animationEventProperties.GetLength(); i < length; i++) { AnimationEventProperty property = animationEventProperties.GetProperty(i); if (property.GetAnimationName() == clipName) { eventProperty = property.GetEventProperties(); lastClipName = clipName; startTime = Time.time; loopReady = false; xCount = 0; break; } lastClipName = clipName; eventProperty = null; startTime = 0; loopReady = true; xCount = 0; } } if (eventProperty != null) { if (Time.time - startTime >= clipLength) { startTime = Time.time; loopReady = false; } else if (!loopReady) { for (int i = 0, length = eventProperty.Length; i < length; i++) { AnimationEventProperty.EventProperty property = eventProperty[i]; if (Time.time - startTime >= property.GetAnimationTime()) { if (xCount == i) { if (property.GetSoundEffect() != null) { audioSource.PlayOneShot(property.GetSoundEffect()); } if (property.GetShakeProperties().GetTarget() != ShakeCamera.ShakeEvent.Target.None) { shakeCamera.AddShakeEvent(property.GetShakeProperties()); } if (i == length - 1) { loopReady = true; xCount = 0; break; } xCount++; } } } } } yield return(null); } }