Search Issue Tracker
Fixed in 2021.1.X
Fixed in 2019.4.X, 2020.2.X, 2020.3.X
Votes
12
Found in
2019.4
Issue ID
1294785
Regression
Yes
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):
using System;
using System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("AssemblyTitle")]
[assembly: AssemblyDescription("AssemblyDescription")]
[assembly: AssemblyCopyright("AssemblyCopyright")]
[assembly: AssemblyCompany("AssemblyCompany")]
[assembly: CLSCompliant(false)]
[assembly: ComVisible(false)]
[assembly: AssemblyVersion("0.0.*")]
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.
Comments (8)
-
ge01f
Oct 17, 2022 17:42
2020.3.37f1 and this is still occurring.
-
Mishganches
Apr 04, 2022 15:35
Same issue for Unity 2020.3.28f1
-
jvella_bhvr
Apr 01, 2022 18:22
This is happening for me in 2020.3.18f1, reopening and a fix would be great thanks.
-
Ash-TA
Nov 11, 2021 07:26
Same issue in 2020.3.19f1 LTS.
-
Jamy4000_Ubisoft
Sep 07, 2021 10:16
Still seeing this issue in 2020.3.16f1, I get a reimport of most of the assets in our projects (resulting in a 20-30 minutes re-import) after changing a couple lines of code.
-
ModLunar
Jul 02, 2021 13:44
It's odd that this is not yet fixed in the latest LTS (Unity 2020.3.13)
-
soleron
Jul 01, 2021 22:37
If it is not fixed on the latest LTS (2020.3.x) you should not mark it as fixed. It is misleading.
-
EP-Toushirou
Jun 03, 2021 11:54
Hello, can Unity 2020.3.12f1 fix this bug?
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Memory leak when a lot of UI elements are spawned and despawned
- Warnings are not logged in the Console window when using external code analyzers
- Errors “TLS Allocator ALLOC_TEMP_TLS, underlying allocator ALLOC_TEMP_MAIN has unfreed allocations, size 288“ appear constantly when Prefab is open
- Crash on PPtr<Shader>::operator or NullException errors spammed in console when calling Dispose() on null GraphicsBuffer with baked Reflection Probes
- “EndRenderPass: Not inside a Renderpass” and other Render Graph errors in the Player when Render Graph is enabled and Overlay UI is used
Resolution Note (fix version 2021.1):
Fixed on:
2021.2.0a2
Backported to:
2021.1.0b5
2019.4.23f1
Resolution Note (fix version 2020.3):
Fixed in 2020.2.4f1