Search Issue Tracker
Fixed in 2017.1.0f3
Votes
0
Found in
2017.1.0b1
Issue ID
902037
Regression
Yes
Project sometimes fail to build due to different serialization order in Editor and Player
Reproduction steps:
1. Open project attached (PartialClassBuild.zip).
2. Build it on standalone player.
Expected result: It will be built successfully.
Actual result: Building stops, output from console: (NOT ALWAYS!)
Error: "Type '[Assembly-CSharp]Player' has an extra field 'FieldTwo' of type 'System.Int32' in the player and thus can't be serialized (expected 'FieldOne' of type 'System.Int32')"
Error: Type '[Assembly-CSharp]Player' has an extra field 'FieldThree' of type 'System.Int32' in the player and thus can't be serialized (expected 'FieldOne' of type 'System.Int32')
Error: "Fields serialized in Editor, class 'Player'
'FieldOne' of type 'System.Int32'
'FieldTwo' of type 'System.Int32'
'FieldThree' of type 'System.Int32'"
Error: "Fields serialized in target platform, class 'Player'
'FieldTwo' of type 'System.Int32'
'FieldThree' of type 'System.Int32'
'FieldOne' of type 'System.Int32"
Error: "Error building player because script class layout is incompatible between the editor and the player."
Note: This does not appear all the time. If it is not reproducible from first time, just makes some changes (add space) in Player.cs.
Reproduced on: 2017.1.0a3, 2017.1.0b1.
Works fine on: 5.6.0p1.
Regression introduced in 2017.
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
- Rigidbody2D.Slide API does not have the needed configuration when creating a 2D Top-Down character controller
- Opening reference for "Playables"component redirects to a missing page
- Sprite Renderer image is changed when switching Mask Interaction and changing Sprite to a shared Sprite
- An unsigned integer is not compared with an integer correctly in player when using IL2CPP backend
- Graphical artifacts are being rendered in Scenes that are loaded during run-time when GPU Resident Drawer is turned on
Superniquito
Oct 09, 2019 02:03
This issue is happening in 2019.3.0b6, and after I removed the asset store package that was throwing the error I got it again in one of my own scripts.
Paul_Bronowski
Jun 12, 2019 05:27
I was incorrect. unsealing the classes did not workaround the problem. It appears to be intermittent. Still looking for a workaround.
Paul_Bronowski
Jun 07, 2019 06:03
The problem appears to be related to serialized fields in sealed partial classes. One possible workaround, which seems to resolve the build error, is to remove the sealed keyword.
Again, I'm on 2018.4.0f1 and my failing case looks like...
// There are 4 files that make this partial class
// None contain public fields, all contain [SerializeField] private fields
public sealed partial class LoaderService
: ServiceMonoBehaviour<LoaderService>
{
}
// No serialized fields here
public abstract class ServiceMonoBehaviour<TService> :
ServiceMonoBehaviour,
IService<TService>
where TService : ServiceMonoBehaviour<TService>
{
}
// No serialized fields here
public abstract class ServiceMonoBehaviour
: MonoBehaviour,
IService
{
}
Cleaning all intermediates/temps does not resolve the build error, nor does building in VS before the command-line build. Note that ProBuilder NuGet package also has the problem in several classes...
namespace UnityEngine.ProBuilder
{
public sealed partial class ProBuilderMesh
Paul_Bronowski
Jun 07, 2019 03:25
FWIW, I'm seeing this with 2018.4.0f1. Same partial class problem with one of my classes and a nuget package, on clean x64 standalone command-line build. Trying to work around it.
h0lmie
May 20, 2019 14:28
Issue is present in 2018.4.0f1 LTS as well. Just updated from 2018.1.6f1 which did not have the issue.
Restarting Unity fixes it, and allows commandline gradlebuilding just fine. Issue seems to reoccur if scripting define symbols get modified, or recompilation in general.
imuzzolini
Jan 09, 2019 15:34
I can confirm that is still present in 2018.2.12f1.
I was able to reproduce the issue as follows:
- open the project with Unity Ediror
- build
- exit the Editor
- make a modification with another text editor to a C# class that is marked with the [Serializable] attribute (e.g., inverting the order of 2 public properties)
- build the project in batch mode (i.e., C:\Unity\2018.2.12\Editor\Unity.exe -batch -projectPath D:\path\to\project\issue...)
- build fails
vizgl
Dec 10, 2018 21:23
Same here. If I build project from editor all works fine, but if I use command line batch build, then build process finished with errors like:
Fields serialized in target platform, class 'UnityEngine.Timeline.TrackAsset'
Aurimasp
Oct 31, 2018 17:05
Hello, could you please report this bug using our bug reporter? We will investigate the issue using updated reproduction project.
DaceZA
Oct 31, 2018 15:46
I can confirm that the issue is still present in Unity 2018.
Tiddan
Oct 31, 2018 01:16
This issue is happening in 2018.2.14f1 as well, so it's clearly not fixed.