- Home /
How (and where) does Unity save the modified parameters of a prefab's instance?
I am using a prefab (say a piece of environment, like a mesh) with some specific behaviour (it has a script as a component attached to it).
Said script contains several variables, preset by default, and many of them accessible in the Editor's inspector, for rapid tweaking. This way, the prefab is sufficiently modular. Now, I produce ten instances of that prefab in a scene by dragging the prefab in the 3D view. Then, I modify some of the values of these instances in the Inspector (tick some cases, change public vars like floats or ints). Not all instances are modified the same way, for the sake of variety. All overriden parameters now appear bolded.
I save the scene. Build for mobile, etc. During runtime, at the beginning, the game will produce a pool of those instances and will manage to retrieve then place each instance as I had put and saved them in the project's scene, with the specific modified parameters. So far so good.
Unity uses a system so as to know, when loading (activating) each instance individually, how to modify them according to my earlier choices.
Now, I'm unsure how nor where Unity saves the data specifically relevant to these overriding parameters. Is it saved in a single global file that can't be reached in the Editor? Is that file attached to the project as a whole, or is it divided into several files, one per scene or per prefab specifically? Or does Unity even produce more of them, one for each instance? What is the way to access and read this or these file(s)?
TL;DR: how does Unity store the list of all instances' modified parameters that will be read later on in game when recreating my scene?
Thx
Answer by DiegoSLTS · Jun 15, 2015 at 06:23 PM
I guess that info is stored in the scene file itself, the .unity file of the scene you're editing.
If you use version control you can easily see that the only file that's modified when you change some of those values is the .unity file.
"How" are the stored? Well... you'll have to understand the .unity file format, you can open the file as text but it's not a file intended for human readers.
Your answer
Follow this Question
Related Questions
Two Instances of same Prefab dealing damage to each other. 0 Answers
Save and load prefabs instantiated at runtime 0 Answers
How do I re-link an object that has unintentionally become detached from prefab? 0 Answers
Script uses transform.position of Prefab instead of Instance 1 Answer
How can I read data from a text file, putting a large amount of data into structures 2 Answers