Example #1
0
 /// <summary>
 /// Generic method to handle all material transitions.
 /// </summary>
 public static void TweenMaterial(GameObject gameObject, Material targetMaterial, float duration, Easing easing, string cubicBezier)
 {
     if (targetMaterial != null)
     {
         Material targetMaterialInstance = Object.Instantiate(targetMaterial);
         CrayonRunner.Instance.Run(CrayonTweenCoroutines.TweenMaterialCoroutine(gameObject, null, targetMaterialInstance, duration, easing, cubicBezier));
     }
     else
     {
         Debug.LogWarningFormat("Material for {0} has not been assigned.", gameObject.name);
     }
 }
Example #2
0
        /// <summary>
        /// Generic method to handle all color-only transitions.
        /// </summary>
        public static void TweenColor(GameObject gameObject, Color targetColor, float duration, Easing easing, string cubicBezier)
        {
            // Create instance of material
            Renderer r = gameObject.GetComponent <Renderer>();

            if (r == null)
            {
                Debug.LogWarningFormat("{0} needs a renderer component.", gameObject.name);
                return;
            }
            Material targetMaterial = Object.Instantiate(r.material);

            targetMaterial.SetColor("_Color", targetColor);
            CrayonRunner.Instance.Run(CrayonTweenCoroutines.TweenMaterialCoroutine(gameObject, null, targetMaterial, duration, easing, cubicBezier));
        }
Example #3
0
        /// <summary>
        /// Generic method to handle all color-only transitions.
        /// </summary>
        public static void TweenColor(GameObject gameObject, Color targetColor, float duration, Easing easing, string cubicBezier)
        {
            // Is this a sprite renderer?
            SpriteRenderer sr = gameObject.GetComponent <SpriteRenderer>();

            if (sr != null)
            {
                Debug.LogWarning("Is a sprite");

                if (CrayonRunner.Instance == null)
                {
                    Debug.LogWarning(CrayonMessages.PrefabMissing);
                }
                else
                {
                    CrayonRunner.Instance.Run(CrayonTweenCoroutines.TweenSpriteCoroutine(gameObject, sr.color, targetColor, duration, easing, cubicBezier));
                }
            }
            else
            {
                // Create instance of material
                Renderer r = gameObject.GetComponent <Renderer> ();
                if (r == null)
                {
                    Debug.LogWarningFormat("{0} needs a renderer component.", gameObject.name);
                    return;
                }
                Material targetMaterial = Object.Instantiate(r.material);
                targetMaterial.SetColor("_Color", targetColor);
                if (CrayonRunner.Instance == null)
                {
                    Debug.LogWarning(CrayonMessages.PrefabMissing);
                }
                else
                {
                    CrayonRunner.Instance.Run(CrayonTweenCoroutines.TweenMaterialCoroutine(gameObject, null, targetMaterial, duration, easing, cubicBezier));
                }
            }
        }