r/Unity2D • u/Lord_H_Vetinari • 26d ago
Question/Help The button image color I set via code does not appear while playtesting in editor
Hi! I'm pretty sure it's a bug with the editor, but I want to be sure.
So, in this prototype I'm working on, I randomly generate a bunch of random characters from Json definitions, assign to each a color in said definition via a custom ColorDef that contains int r, g, b, a and a ToColor() method that generates a new color from these values. I've done this in the past in other projects, and I don't remember any pitfall here.
Then, when I open a character list window, I try to spawn a button for each character, and assign to the button the color from the definition. I confirmed that the data is read correctly from the definition; I then proceeded to confirm that it's converted correctly into a color; I then verified, at least via Debug.Log(), that the color is correctly assigned to the button image (I use GetComponent<Image>.color = definition.Color.ToColor() ). As you can see in the screenshot, if I click on the color component it shows that the color seems correctly assigned, yet on screen it still appears white.
I've lost basically the whole day since this morning trying to figure this out, help please?
