Search Issue Tracker

Active

Planned for 2019.4, 2020.2

Votes

12

Found in

2019.4

Issue ID

1294785

Regression

Yes

Prefabs are reimporting every time a code change is made

Asset Import Pipeline

-

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.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.