I have read a couple of questions regarding the workflow of prefabs and model assets. I still don't get it. Is it supposed to be this hard to work with models? I can't seem to get anything done and I consider myself reasonably experienced in Unity so it feels kind of embarrasing. All the time I get problems with models being changed and prefabs not picking up the changes. Sometimes it feels like I am a card house architect in a perfect storm.
Currently we're using the approach of creating an empty game object, placing the model as child of this and make a prefab of the whole. We then never add any components directly to the model but let scripts do the work runtime. This works for mesh changes but as new transforms are added to the model, they are not added to the prefab. I also respect the solution offered with post asset processing but it's is sort of backwards having the model become the code and responsibilities. It works for basic things but as soon as things get a bit complicated you'd end up with a programming language embedded inside model names.
This workflow is, in my own words, rubbish (sorry, but it is horrible to work like this). I dont understand if this is some flaw in how Unity is designed, or a flaw of our understanding of Unity. I find our approach highly error prone and unreliable. Bugs creep in as expected transforms aren't available, sometimes nested deep in hierarchy. How are you coping with these changes? Are you just accepting the reality or have you worked out a way to cope with changes unintrusively?
The "best" theoretical solution I thought about was to have a script that executes in edit mode (for visible model during editing), which during OnEnable instantiates and parents a model so it always get a fresh model each run. It is not without problems, because it still means we can't touch the model in design time and it becomes awkward to update the prefab since you have to remove the model to ensure you won't save it to the prefab.
- The bottom line question is: How can I make prefabs that don't break when models change?
Thank you very much for taking your time reading this.
Update about how to reproduce our current issues in response to comments:
I don't have a model to spare right now but I might be able to post a full reproduction tomorrow.
- Create a model and import it to Unity.
- Create an empty game object and attach model as child to this.
- Create an empty prefab and drag the newly created object to the prefab.
- Alter the model (add a cube or something) and reimport it to Unity.
- Now prefab won't have the extra cube, but if you drag out a new model, it will have.
This is a minimal reproduction but you can imagine it becomes a bit troublesome if you have several prefabs with several scripts all accessing several models. On a small scale it is manageable but as your scene starts to grow it becomes more and more painful to cope with the changes in prefabs.