// Author: Daniele Giardini - http://www.demigiant.com // Created: 2018/06/01 10:49 // License Copyright (c) Daniele Giardini // This work is subject to the terms at http://dotween.demigiant.com/license.php using DG.Tweening.Core; using DG.Tweening.CustomYieldInstructions; using UnityEngine; namespace DG.Tweening { /// /// Methods that extend Tween objects and allow to control or get data from them. /// These require at least Unity 5.3 /// public static class TweenExtensions53 { #region Custom Yield Instructions /// /// Returns a that waits until the tween is killed or complete. /// It can be used inside a coroutine as a yield. /// Example usage:yield return myTween.WaitForCompletion(true); /// public static CustomYieldInstruction WaitForCompletion(this Tween t, bool returnCustomYieldInstruction) { if (!t.active) { if (Debugger.logPriority > 0) Debugger.LogInvalidTween(t); return null; } return new DOTweenCYInstruction.WaitForCompletion(t); } /// /// Returns a that waits until the tween is killed or rewinded. /// It can be used inside a coroutine as a yield. /// Example usage:yield return myTween.WaitForRewind(); /// public static CustomYieldInstruction WaitForRewind(this Tween t, bool returnCustomYieldInstruction) { if (!t.active) { if (Debugger.logPriority > 0) Debugger.LogInvalidTween(t); return null; } return new DOTweenCYInstruction.WaitForRewind(t); } /// /// Returns a that waits until the tween is killed. /// It can be used inside a coroutine as a yield. /// Example usage:yield return myTween.WaitForKill(); /// public static CustomYieldInstruction WaitForKill(this Tween t, bool returnCustomYieldInstruction) { if (!t.active) { if (Debugger.logPriority > 0) Debugger.LogInvalidTween(t); return null; } return new DOTweenCYInstruction.WaitForKill(t); } /// /// Returns a that waits until the tween is killed or has gone through the given amount of loops. /// It can be used inside a coroutine as a yield. /// Example usage:yield return myTween.WaitForElapsedLoops(2); /// /// Elapsed loops to wait for public static CustomYieldInstruction WaitForElapsedLoops(this Tween t, int elapsedLoops, bool returnCustomYieldInstruction) { if (!t.active) { if (Debugger.logPriority > 0) Debugger.LogInvalidTween(t); return null; } return new DOTweenCYInstruction.WaitForElapsedLoops(t, elapsedLoops); } /// /// Returns a that waits until the tween is killed or has reached the given position (loops included, delays excluded). /// It can be used inside a coroutine as a yield. /// Example usage:yield return myTween.WaitForPosition(2.5f); /// /// Position (loops included, delays excluded) to wait for public static CustomYieldInstruction WaitForPosition(this Tween t, float position, bool returnCustomYieldInstruction) { if (!t.active) { if (Debugger.logPriority > 0) Debugger.LogInvalidTween(t); return null; } return new DOTweenCYInstruction.WaitForPosition(t, position); } /// /// Returns a that waits until the tween is killed or started /// (meaning when the tween is set in a playing state the first time, after any eventual delay). /// It can be used inside a coroutine as a yield. /// Example usage:yield return myTween.WaitForStart(); /// public static CustomYieldInstruction WaitForStart(this Tween t, bool returnCustomYieldInstruction) { if (!t.active) { if (Debugger.logPriority > 0) Debugger.LogInvalidTween(t); return null; } return new DOTweenCYInstruction.WaitForStart(t); } #endregion } }