- Home /
Fill an image with multiple colors?
Hi!
I'd like to fill an image with multiple colors (see image below) using built in unity assets. Problem is I don't know how many colors there will be, so I can't use multiple images above each other. The length of each color would be based on percentages. Question is: is this possible with Image or any other built in asset? Or am i just better off buying something from asset store?
Answer by EdwinChua · May 18, 2017 at 08:49 AM
@JedBeryll You can indeed use multiple images. What you need is:
Use a white ring image
Set it to radial fill
Save it as a prefab
When you want to use it:
Instantiate via script for each color you need
Set the color appropriately (In my case, I prepared 20 mats/colors so I wouldn't run out)
Either calculate rotation or fill it out to color the necessary portion
i.e. color1 = 1; color2 = 1-color1.value; color3 = 1-(color1.value+color2.value);
I've provided you with the circle I used. Hollow it out to make your ring.
Answer by Bunny83 · May 19, 2017 at 08:36 AM
There was a quite similar question some time ago. Though he didn't just asked for a visual representation but for a radial multi-color slider. I wrote such a script back then. I just posted an updated version that allows scaling and rotating of the whole slider.
The script could be modified to just allow the visuals without any interaction.
Nice! I already worked out what i needed but i'll check yours, see if I can improve my version.
Your answer
![](https://koobas.hobune.stream/wayback/20220612122249im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Image Fill Bug 0 Answers
Image custom fillOrigin 1 Answer
Image Filling To Obtain Color Scale 0 Answers