Hey guys,
I am making a small mobile App for my son which features a color by numbers with images he likes.
I build the app now and it all seems to work fine.
However they way it has been set up is that i cut images into small pieces, import these into unity and treat them as individual sprites which get then coloured accordingly. This seems to be overly complex in regards to adding more images so I was wondering which approach would be best from your point of view ?
I was wondering on wether it is possible to have a fully coloured images and just draw in the lines and have a shader that colors all white and then treats each section as individual object to reveal the color… Or are there any other possibilities from your point of view?
There are a lot of ways you could do this. How I’d do it personally though… I’d just make the black lines in the image completely transparent. This would leave empty space between the sections. Then import the image as a sprite in Sprite Mode Multiple. Open the Sprite Editor and click Slice at the top left, then slice it as Automatic. This should slice the image into separate sprites for each section. You’d still have separate sprites by section this way, but it’d be a lot faster to do this than to manually cut the image up into separate images.
Other possibilities:
- Color swap shader is definitely possible, but I wouldn’t recommend it. You’d still have to do some sort of input detection for each section individually. If you do color swap with just one image, you’d have to manually create colliders for each section to detect input.
- You could make an editor menu button that takes a selected image and uses Texture.ReadPixels() to detect sections and create separate textures for each section. It could save all those sections to one ScriptableObject by the name of the image. Then you’d create a system that could take that scriptable object and automatically create all the objects and components you need for it to be separate sections. This would be an overly complex method that would take a lot of work to get right, but it would technically automate the import process besides maybe adding numbers to section if that’s necessary.