0
\$\begingroup\$

I'm trying to make a coloring game, of which I already have a drawing (outline) of an object - let's say a face of a dog. How can I do it that whenever I click for example the eyes, it will "fill" any empty space inside the eye part of the image to a specific color?

The other solution I have of this is to manually export each "spaces" I want the player to color [ex: eyes, mouth, nose, and empty face]. And then I would just assemble back these images to their correct placements to give an illusion that's just one whole image of a dog's face. The player can now click the nose, and the nose's color would then change.

This is nice for simple images with 4-5 parts. But for example abstract looking drawings where it has like 70-100 spaces, exporting them and then assembling them 1 by 1 would be such a tedious task. Is there any way I could just import the outline drawing in Unity, and let Unity automatically detects these spaces for me?

\$\endgroup\$
4
  • \$\begingroup\$ Maybe a flood fill would help you in case you don't want to seperate it fully into small pieces \$\endgroup\$
    – Zibelas
    Sep 20 at 18:14
  • \$\begingroup\$ @Zibelas Yes exactly! Something like a flood fill would be a great solution. However though I don't anything about it in Unity. Could you give some ideas on how to do a flood fill in Unity? \$\endgroup\$
    – DC37
    Sep 20 at 18:15
  • \$\begingroup\$ Have you tried to search youtube or similar for a basic tutorial on it and you are struggling with a specific part of implementing it? In that case please post your code, what is not working and any error, if you have some. \$\endgroup\$
    – Zibelas
    Sep 20 at 18:22
  • 1
    \$\begingroup\$ There's nothing special about Unity that changes how you would implement a standard algorithm like a flood fill. You write the algorithm in your own code, following existing tutorials that explain how, then write the results into your texture using Texture.SetPixels() or SetPixels32(), which you can find explained in the Unity API documentation, then call Apply() to send the updated version to the GPU. \$\endgroup\$
    – DMGregory
    Sep 20 at 18:39

0

You must log in to answer this question.

Browse other questions tagged .