ZTweenSurrogate.cs 794 B

1234567891011121314151617181920212223242526272829
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. public class ZTweenSurrogate:MonoBehaviour {
  4. // Tween surrogate, to control its updating
  5. private List<ZTween.ZTweenSequence> tweenSequences = new List<ZTween.ZTweenSequence>();
  6. void Update() {
  7. for (int i = 0; i < tweenSequences.Count; i++) {
  8. if (tweenSequences[i] != null) {
  9. tweenSequences[i].update();
  10. } else {
  11. tweenSequences.RemoveAt(i);
  12. i--;
  13. }
  14. }
  15. }
  16. internal void add(ZTween.ZTweenSequence tweenSequence) {
  17. tweenSequences.Add(tweenSequence);
  18. }
  19. internal void remove(ZTween.ZTweenSequence tweenSequence) {
  20. // Nullify first, remove later - otherwise it gets remove while doing Update(), which can cause the list to trip on itself
  21. tweenSequences[tweenSequences.IndexOf(tweenSequence)] = null;
  22. }
  23. }