Overwriting a prefab in runtime?

I am working on a randomly generated game, and the random generation would include the character’s looks. I’m sure I would use this for other things, but for now I’ll just stick with the character example. So at the start of a scene, let’s say the character’s hair color is randomly generated. When the player exits the scene, and it loads the next one, I want that character to have the same hair color. I have a script that spawns the player at a certain position in this scene using the “Player” prefab.

So let’s say the original player prefab had black hair, and then at the start of a scene the hair color was changed to red. Now I want to save that new player into the “Player” prefab, so that in the next scene, I can spawn the “Player” prefab and it will still have the red hair that was chosen in the last scene. That’s the best example I can think of. So basically, is there a way to overwrite a specific prefab with a new gameobject during runtime?


I read something online about being able to do it with editor scripts, but I couldn’t find anything on what exactly that means. Could anybody point me in the right direction?

I think what you really are looking to do is create some kind of save game or store user preferences. When the game loads, or when the next scene loads, you can look up the preferences for your character and pick the correct set of appearance.

If you want to be able to do this at runtime when players are playing your game, you can’t solve it with any editor scripts since the editor scripts are only available while developing the game. Editor scripts are scripts that makes it easier for developers to make games, simply put.