Пример #1
0
        /// <summary>
        /// Generic method to handle all opacity transitions.
        /// </summary>
        public static void Fade(GameObject gameObject, FadeDirection fadeDirection, float opacity, float duration, Easing easing, bool destroy, string cubicBezier)
        {
            Transform[] objectAndChildren = gameObject.GetComponentsInChildren <Transform> ();
            // If there are child objects, loop through them
            for (int i = 0; i < objectAndChildren.Length; i++)
            {
                // TODO: Provide a check to see whether the child component already has this code.
                // I was hitting issues before where child objects were not fading in because they had their own
                // components calling the same coroutine

                // Check to see if there's a renderer before trying to tween
                if (objectAndChildren [i].gameObject.GetComponent <Renderer> () != null)
                {
                    if (CrayonRunner.Instance == null)
                    {
                        Debug.LogWarning(CrayonMessages.PrefabMissing);
                    }
                    else
                    {
                        CrayonRunner.Instance.Run(CrayonTweenCoroutines.FadeCoroutine(objectAndChildren [i].gameObject, fadeDirection, opacity, duration, easing, destroy, cubicBezier));
                    }
                }
                else
                {
                    Debug.LogWarningFormat("{0} will not tween because it does not contain a Renderer component.", objectAndChildren [i].gameObject.name);
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Generic method to handle all opacity transitions.
 /// </summary>
 public static void Fade(GameObject gameObject, FadeDirection fadeDirection, float opacity, float duration, Easing easing, bool destroy, string cubicBezier)
 {
     Transform[] objectAndChildren = gameObject.GetComponentsInChildren <Transform> ();
     // If there are child objects, loop through them
     for (int i = 0; i < objectAndChildren.Length; i++)
     {
         // TODO: Provide a check to see whether the child component already has this code.
         // I was hitting issues before where child objects were not fading in because they had their own
         // components calling the same coroutine
         CrayonRunner.Instance.Run(CrayonTweenCoroutines.FadeCoroutine(objectAndChildren[i].gameObject, fadeDirection, opacity, duration, easing, destroy, cubicBezier));
     }
 }