using UnityEngine; namespace Chronos { /// /// A component that transfers the effects of any ancestor Timeline in the hierarchy to the current GameObject. /// [AddComponentMenu("Time/Timeline Child")] [DisallowMultipleComponent] [HelpURL("http://ludiq.io/chronos/documentation#Timeline")] public class TimelineChild : TimelineEffector { /// /// The parent Timeline from which time effects are transfered. /// public Timeline parent { get; private set; } protected override Timeline timeline { get { return parent; } } protected override void Awake() { CacheParent(); base.Awake(); } /// /// The timeline hierarchy is cached for performance. If you change the transform hierarchy, you must call this method to update it. /// public void CacheParent() { var previousParent = parent; parent = GetComponentInParent(); if (parent == null) { throw new ChronosException("Missing parent timeline for timeline child."); } if (previousParent != null) { previousParent.children.Remove(this); } parent.children.Add(this); } } }