Adding a Color wheel through a script?

Hi Guys

I made a script, and attached 2 sprites to it from the inspector panel, but unlike the sprite renderer component I don’t have a color wheel to set their color. So how should I do this? Is it possible to add a color wheel through a script if yes, then how, if not, then what would you recommend I do?

Thanks.

You mean you just want a public Color variable where you can choose the color in the inspector (which you click on to bring up the color palette?)

Or are you trying to do something else? (you mention color wheel, so I just want to make sure)

1 Like

Hi,

Yes, that’s exactly what I’m trying to achieve. Is it possible?

Just declare a colour variable and it will show up in the inspector

Public Color VariableName
2 Likes

Hi @JoePatrick

I declared the variable and it does show up in the inspector but it doesn’t change the sprites color, so how should I make it change the sprites color?
I’m a newbie so please don’t mind.

You would need to then apply the colour.
The easiest way would be to set the SpriteRenderer colour

SpriteRenderer sp = gameObject.GetComponent<SpriteRenderer>(); //Put this in Start()
sp.color = VariableName; // Put this in Update()

Generally I don’t suggest using update to apply something over and over. (unless we have no other choice).

So, for the color, is this something your player can change while in game or is it something you set and then apply once?

No, its not something the player can change, I just need to apply it once in the inspector.

Thanks alot @JoePatrick , it worked for me but I didn’t need to update the color so I made a separate function to Load the Sprites and put this code in there and its working fine.

Yeah if you only need to update once then don’t put it in Update(), just put it in Start()

1 Like

Hey, I know this thread is old, but i wanna have the player choose a color from the colorwheel, how can i make it possible?

Asset store.