Reputation: 678
I have a class that looks like this:
public class ColorSwap : MonoBehaviour
{
public Color color;
void Start(){
this.getComponent<SpriteRenderer>().color = color;
}
}
I've set the color in the inspector. I can see it set.
I tried using this.getComponent().color = color;
but it didn't work.
Upvotes: 2
Views: 10080
Reputation: 678
Ironically, the problem was that the "color" struct was auto initialized to Color(0,0,0,0);
When changing the color in the color picker, the Hue changes, but not the Alpha.
So, even though I thought I set it to (1.0, 0, 0), it was actually set to (1.0, 0, 0, 0);
Upvotes: 3