I want to build sort of a dress doll in 2D. A set of images, head, torso, legs, arms
and in run mode I want to manipulate the colors of each item.
My question is, Where do I put my images?
I’ve tried making a GameObejct and putting all my images inside of it but it turns invisible for some reason.
I’ve tried putting them on sprites and on UI images but I don’t know how to keep them as a collection so I can make a prefab out of it.
I kinda need them inside a container because I want to be able to drag & drop a “full character” in run mode.
Just put the image files in whatever folder you want- definitely import them as sprites, and then just assign them to SpriteRenderers to display them in the scene.
If you just want a single avatar, a prefab works. Make a GameObject in the scene to serve as the root object, then make additional GameObjects as children, each with their own SpriteRenderer component attached and with your body part sprites assigned to them. You can then put a new script on the root object, make 4 public/serialized fields for SpriteRenderer references (HeadSprite, BodySprite, LegSprite, ArmSprite) and drag and drop the children into the appropriate slots in the inspector. You should then be able to manipulate the colours of each of the sprites, among other things, from that one script. In order to re-use this setup repeatedly in different scenes, just drag the root GameObject down into the project files to create a prefab out of it.
However, if you want to manage things a bit more dynamically, you can set up a collection in a ScriptableObject to serve as your “sprite database”, then request sprites from the database when you need them in the scene. This is a bit more involved, but with a little work you can create a kind of wardrobe system where you can swap out the various body parts as needed with alternate designs. The prefab suggestion earlier would still be a part of that, but instead of pre-set sprites in the child SpriteRenderer components, you would assign those sprites in Start in your custom script on the root object, pulled from the ScriptableObject database by ID or name as needed.
This is an older tutorial at this point, but still applicable in newer Unity versions and I highly recommend watching it if you haven’t already, just FYI (watch all 6 tutorials in that video series, even). Also this one on ScriptableObjects- it’s long but well worth it.
Thank you very much Lysander. I’m going to read through and research what you said. this is great. I don’t know most of these things so it’ll keep me busy for a while.