- Home /
(C#) Changing color of SpriteRenderer in script causing gameObject to not render
I have a bunch of 2D sprites in my game, all Instantiated from prefabs. I want to change the color of the SpriteRenderer according to a float value, but whenever I do so through this code:
gameObject.GetComponent<SpriteRenderer>().color = colours[someInt];
the gameobject isn't rendered at runtime. If I comment out that line, it renders
colours is an array of type Color, which I have populated The shown line is inside Update(), and the script is attached to the prefab
Answer by Naphier · Mar 02, 2018 at 07:55 PM
What's in colours array? Are they all transparent?
You solved it. They were all transparent. $$anonymous$$e being dumb. I keep forgetting which end of the alpha bar is transparent. Thanks a ton
Your answer
Follow this Question
Related Questions
How to FadeIn 3dObject using alpha color? 1 Answer
How to change color property of the Sprite Renderer in C# 1 Answer
Change the background color attribute of a camera in C#? 2 Answers
Strange artifacts in builds 0 Answers
Distribute terrain in zones 3 Answers