Creating a prefab variant is simple. Doing it for 5 prefabs is harder. Doing it for 5 prefabs and replacing images and localization terms is a drag. So I created a script that does just that.
In our game we have prefabs that we need to skin multiple times. Having to do this by hand would mean copy the base prefab as a variant then replace all needed images and localization terms. We had to do this for a great number of prefabs so we needed a script to automate this.
The script asks you for a skin name and a list of prefabs. The skin name will be used as a suffix for the variant copies. Each base prefab is checked for image components and then the script tries to see if there is a version of that image with the skin name suffix attached. New skin images are always exported with their skin name suffix using generic names. If a version of the image is found with correct suffix, the image is replaced (native size is also set and if the original image is sliced for example that will also be copied to the new image file) Is the image name with suffix not found, the original image is kept. The same is done for localization terms. If a version of the localization term exists with the skin name suffix, it is replaced, if not the original is kept.When everything is replaced the new prefab variant is set as addressable with the correct label in the correct group. There is still some manual work to be done (image positions can vary, content can vary etc.) but this brings us to 70% in a single click.
No comments:
Post a Comment