/// <summary> /// Fades a GameObject (and its children) to zero opacity, and destroys the GameObject when complete. /// </summary> /// <param name="gameObject">The GameObject to fade out.</param> /// <param name="duration">The duration of the fade.</param> /// <param name="easing">Easing, specified as a string, ex. "cubic."</param> /// <param name="cubicBezier">If using Easing.Custom, this is the cubic bezier curve that defines the easing function, in the format P0,P1,P2,P3.</param> public static void FadeOutAndDestroy(this GameObject gameObject, float duration, string easing, string cubicBezier = Defaults._cubicBezier) { CrayonRouter.Fade(gameObject, FadeDirection.Out, 0.0f, duration, Utils.GetEasing(easing), true, cubicBezier); }
/// <summary> /// Instantiates a GameObject and fades it to full opacity. /// </summary> /// <param name="gameObject">The GameObject to instantiate and fade.</param> /// <param name="transform">The transform where the GameObject should be instantiated.</param> /// <param name="duration">The duration of the fade.</param> /// <param name="easing">Any easing that the transition should follow.</param> /// <param name="cubicBezier">If using Easing.Custom, this is the cubic bezier curve that defines the easing function, in the format P0,P1,P2,P3.</param> public static void FadeInNew(this GameObject gameobject, Transform transform, float duration, Easing easing, string cubicBezier = Defaults._cubicBezier) { gameobject = GameObject.Instantiate(gameobject, transform.position, transform.rotation); CrayonRouter.Fade(gameobject, FadeDirection.In, 0.0f, duration, easing, false, cubicBezier); }
/// <summary> /// Fades a GameObject (and its children) to zero opacity. /// </summary> /// <param name="gameObject">The GameObject to instantiate and fade.</param> /// <param name="duration">The duration of the fade.</param> /// <param name="easing">Easing function that the transition should follow.</param> /// <param name="cubicBezier">If using Easing.Custom, this is the cubic bezier curve that defines the easing function, in the format P0,P1,P2,P3.</param> public static void FadeOut(this GameObject gameObject, float duration = Defaults._duration, Easing easing = Defaults._easing, string cubicBezier = Defaults._cubicBezier) { CrayonRouter.Fade(gameObject, FadeDirection.Out, 0.0f, duration, easing, false, cubicBezier); }
/// <summary> /// Instantiates a GameObject and fades it to full opacity. /// </summary> /// <param name="gameObject">The GameObject to instantiate and fade.</param> /// <param name="duration">The duration of the fade.</param> /// <param name="easing">Any easing that the transition should follow.</param> /// <param name="cubicBezier">If using Easing.Custom, this is the cubic bezier curve that defines the easing function, in the format P0,P1,P2,P3.</param> public static void FadeInNew(this GameObject gameObject, float duration = Defaults._duration, Easing easing = Defaults._easing, string cubicBezier = Defaults._cubicBezier) { gameObject = GameObject.Instantiate(gameObject, Vector3.zero, Quaternion.identity); CrayonRouter.Fade(gameObject, FadeDirection.In, 0.0f, duration, easing, false, cubicBezier); }