Color picker?

Color picker?
How can I make the color picker
(example) for some sprites in my game (eg car doors)

Welcome @alp !
The one example that comes to my mind:

With this you can use the picked color and apply it to the sprite (GUI image node’s color or sprite’s tint) depending on if you want to make the car in GUI or as a sprite in game object :slight_smile:
If you will tinker a little bit with it you should be able to create a simple example, where you pick a color and the picked color is applied to sprite/gui node. If you will face any problems, just let us know :wink:

Edit: I tested the color picker by @ross.grams, but it uses custom render script and material to modify displayed colors, so you will probably need to digest into this topics a little bit.

If you are looking for an even simpler solution you can think about for example - predefined pallete presented to user to choose a color from (it could be as simple as showing few gui nodes and applying tint to sprite/ color to another gui node with car parts.) or showing a pallete image and picking position where user clicked and calculating the picked color basing on the position. There are few possibilites, so please, consider, what could be the best for you :wink:
If you are just starting, make a simple prototype, where you choose between e.g. 2-3 predefined colors and according to the selection tint the sprite :slight_smile:

5 Likes

Boy, I made that a long time ago. I’m sure it could be improved.

To have a dynamic color picker, I believe you do need to send some data to the shader, so I think you do have to modify the render script a bit to do that, but that’s only a couple of lines.

To display the color picker, basically you have a simple fragment shader that uses the UV coordinates (var_texcoord0) to choose the color for that pixel. Then in your lua code, you convert the mouse coordinate to UV coordinates and use the exact same formula to get the color.

2 Likes

I thought color palettes might be the better choice and I came to the conclusion.:sweat_smile:
Thank you!

3 Likes