Search Issue Tracker
Fixed in 2021.1.X
Fixed in 2019.4.X, 2020.2.X, 2020.3.X
Prefabs are reimporting every time a code change is made
Based on the discussion on this forum thread: https://forum.unity.com/threads/prefabs-are-reimporting-every-time-a-code-change-is-made.939756
I was discovered that when the following conditions aligned, all Prefabs with a [SerializeField] attribute in a Script were reimporting:
1. Create a project
2. Create a Prefab (PrefabA)
3. Create a new Monobehaviour (i.e. ScriptA.cs)
4. Create another Monobehaviour (i.e. ScriptB.cs)
5. Add ScriptA & ScriptB to a prefab.
6. In Script A, add a private variable:
[SerializeField] private ScriptB scriptReference;
7. Add a new Script that contains this (AssemblyStaticInfo.cs):
8. Create a new script (UnrelatedScript.cs)
9. Modify that script, and notice that EVERYTIME UnrelatedScript is modified, PrefabA is reimported.
10. Remove the [SerializeField] from ScriptA
11. Notice the Prefab no longer reimports.
Expected: Unrelated code changes should not reimport prefabs.
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
- Fields are not focused correctly when using UI Builder
- UNITY_SERVER scripting define does not work when switching to Dedicated Server from Windows by script
- Mesh.CombineMeshes discards empty sub-meshes when 'mergeSubmeshes' is set to false
- [Linux] MacOS build fails for every architecture when the project contains a "StreamingAssets" folder with empty an "yaml" file
- Property drawers do not always update height correctly when expanded via iteration