/// <summary> /// Returns a Tween instance that is configured to animate the alpha channel of a /// Material.color property. Note that this function relies on the target component /// having a renderer whose sharedMaterial property has been assigned. If it has not, /// a NullReferenceException will be thrown. /// </summary> /// <param name="component"></param> public static Tween <float> TweenAlpha(this Component component) { // Special cases for components which have a specific color, renderer, or material property if (component is TextMesh) { return(TweenTextExtensions.TweenAlpha((TextMesh)component)); } else if (component is GUIText) { return(TweenMaterialExtensions.TweenAlpha(((GUIText)component).material)); } else if (component.GetComponent <Renderer>() is SpriteRenderer) { return(TweenSpriteExtensions.TweenAlpha((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.TweenAlpha(material)); }
public static Tween <float> Alpha(Material material) { return(TweenMaterialExtensions.TweenAlpha(material)); }