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

Serialization

-

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.

Comments (21)

  1. skoteskote

    Sep 23, 2022 10:00

    Just got this issue on 2021.3.10f1, reloading script assemblies resolved it.

  2. lolerji

    Apr 17, 2022 10:53

    Still happens on 2020.3.30f1. This is not resolved.

  3. ShahAhmed1

    Nov 22, 2021 09:35

    Simply
    Delete those scripts and restore from recycle bin

  4. JanBaaootbg

    May 20, 2021 09:25

    I just had the same error with referring to UnityEngine.UI.InputField with v.2021.1.7.f1.

    The only thing that worked for me was:
    - uninstall all unity versions
    - uninstall unity hub
    - delete temp and appdata unity files
    - remove unity keys from registry under Computer\HKEY_CURRENT_USER\SOFTWARE

    After reinstalling the errors are gone …

  5. Ghosthowl

    Mar 24, 2021 09:43

    Just had the same error in 2020.3.0f1.

  6. Trungdv

    Jan 30, 2021 01:46

    The error also appears in Unity 2019.4.16f1

  7. LMMWidowGames

    Jun 18, 2020 19:20

    Hi,

    This issue happened to me with an abstract class that inherits from Monobehaviour. I think the issue appears when the abstract class has public fields that, in theory, can be serialized by Monobehaviour. If another class inherits from this abstract class and is added as component, the editor will work fine but crashes when building.

    As a workaround I tagged the fields of the abstract class as [HideInInspector] and I have been able to build fine.

    Hope this workaround helps you.

  8. AlejandroBA7

    Feb 08, 2020 00:44

    The error also appears in Unity 2019.3.0f6

  9. sandeepkiks

    Jan 17, 2020 08:59

    This issue again happens in Unity 2019.3.0f5

  10. fsedarkalex

    Dec 14, 2019 12:04

    Still happening with 2019.2.16f1. I am just uploading a bug report.

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.