LocalClock.cs 942 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. using UnityEngine;
  2. namespace Chronos
  3. {
  4. /// <summary>
  5. /// A Clock that only affects a Timeline attached to the same GameObject.
  6. [AddComponentMenu("Time/Local Clock")]
  7. [DisallowMultipleComponent]
  8. [HelpURL("http://ludiq.io/chronos/documentation#LocalClock")]
  9. public class LocalClock : Clock
  10. {
  11. protected override void Awake()
  12. {
  13. base.Awake();
  14. CacheComponents();
  15. }
  16. #region Fields
  17. protected Timeline timeline;
  18. #endregion
  19. /// <summary>
  20. /// The components used by the local clock are cached for performance optimization. If you add or remove the Timeline on the GameObject, you need to call this method to update the local clock accordingly.
  21. /// </summary>
  22. public virtual void CacheComponents()
  23. {
  24. timeline = GetComponent<Timeline>();
  25. // 临时去除报错
  26. //if (timeline == null)
  27. //{
  28. // throw new ChronosException(string.Format("Missing timeline for local clock."));
  29. //}
  30. }
  31. }
  32. }