Creature_Unity
Creature_Unity copied to clipboard
[Muli-Skin] dynamically build Texture2Ds
This is still a WIP
I have all the code working to allow for swapping of equipment and base skins. The developer can customize it any which way by creating a single "regions" JSON file (see attached). This is just a bunch of named rectangles, like "helmet" and "face" in the attached example. Then, the developer can use the new "Creature Material Packer" script I built by assigning a default material, an array of skins, and the regions JSON file. Finally, when the developer wants to actually swap something, it's as simple as SetAttachment("helmet", "Equip_Silver") or SetAttachment("face", "Skin_Pale") to continue with our example.
I optimized the code a bit so it always does incremental asset-building. That is: it caches the last texture for any given Creature, only edits the texture when something changes, and does so incrementally such that it only copies the changed asset. I've got it building for iOS and so far the performance looks good. I tested this by having it swap the helmet between bronze & silver every 0.2 seconds in order to simulate a player rapidly equipping and unequipping items.