/// <summary> /// Returns a Tween instance that is configured to animate a Material.color property. /// Note that this function relies on the target having a renderer whose material property /// has been assigned. If it has not, a NullReferenceException will be thrown. /// </summary> /// <param name="component">The Monobehavior whose color will be animated.</param> public static Tween <Color> TweenColor(this Component component) { // Special cases for components which have a specific color property if (component is TextMesh) { return(TweenTextExtensions.TweenColor((TextMesh)component)); } else if (component is GUIText) { return(TweenMaterialExtensions.TweenColor(((GUIText)component).material)); } else if (component.GetComponent <Renderer>() is SpriteRenderer) { return(TweenSpriteExtensions.TweenColor((SpriteRenderer)component.GetComponent <Renderer>())); } if (component.GetComponent <Renderer>() == null) { throw new NullReferenceException("Component does not have a Renderer assigned"); } var material = component.GetComponent <Renderer>().material; if (material == null) { throw new NullReferenceException("Component does not have a Material assigned"); } return(TweenMaterialExtensions.TweenColor(material)); }
public static Tween <Color> Color(Material material) { return(TweenMaterialExtensions.TweenColor(material)); }