Search Unity

Attempting to get/set properties of "_AlphaMult" on a material

Discussion in 'Scripting' started by BenMiller, May 24, 2019.

  1. BenMiller

    BenMiller

    Joined:
    Feb 13, 2013
    Posts:
    5
    I want to ultimately fade in the Alpha Multiplier on start, but can't seem to figure out how to get the properties within my code.

    Screen Shot 2019-05-24 at 9.20.00 AM.png Screen Shot 2019-05-24 at 9.22.04 AM.png
    The following give me an error of "cannot convert from 'float' to 'UnityEngine.Color'

    var myMaterial = GetComponent<Renderer>().material;

    myMaterial.SetColor("_AlphaMult",myFloat);


    Can anyone help?
     
  2. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,634
    Instead of SetColor, use SetFloat. SetColor is only for colors.
     
  3. BenMiller

    BenMiller

    Joined:
    Feb 13, 2013
    Posts:
    5
    That was it! I knew it was something simple. Thank you!!