I would like to know some better coding patterns to load assets based on player settings. Say that users are allowed to select 1 of many skins for a weapon. Now when I load that weapon object, I want the assets for that skin to be loaded instead of the default.
My question is: what is a good coding pattern to store the user's skin choice, and to read/use this stored data to programmatically load a prefab or texture later?
Right now, what I have is a scroll view with buttons that show each unique skin. When the button is pressed, it saves the skin texture's file name to JSON. Then, later, when I want to figure out what to use, I read that field from JSON and call Resources.Load() on the file name.
Is there a better way to do this? This is very manual and error prone since I have to specify the texture's file name in my code for each button. Right now I'm trying to grab the texture's file name via Image.sprite.name, but this also has a level of manual work involved. It requires knowing which subdirectory of the Resources folder the sprite is in.