Hi ,
I have a problem with a script migrating from Unity 3 to version 4.
My script has some preprocessor directives for Platform Dependent Compilation.
On Windows and in the Editor i override the existing UnityEngine.Touch class with a custom class. On IOS i use the original class from Unity.
Until now (Unity 3.5) I had no compilation problems, but with Unity 4.0 when I try to Build for IOS I get some compilation errors:
Type 'XTInputManager' has an extra field 'activeInputTouches' of type 'System.Collections.Generic.List<UnityEngine.Touch>' in the player and thus can't be serialized
UnityEditor.HostView:OnGUI()
Type 'XTTouchFrameData' has an extra field 'touch' of type 'UnityEngine.Touch' in the player and thus can't be serialized (expected 'hit' of type 'UnityEngine.RaycastHit')
UnityEditor.HostView:OnGUI()
Error building player because script class layout is incompatible between the editor and the player.
Don’t know what the problem is right now, as it works in the editor, so it can’t be a problem with overriding the existing class.
It seems to me that the Implementation of Unity has changed.
Any hints are welcome.
Those errors seem to suggest that you have some serializable member variables inside some preprocessor directives. Unity no like those.
2 Likes
I fixed the problem with using the [NonSerialized] attribute on the fields that causing the errors.
1 Like
Also for me adding [System.NonSerialized] on the attribute causing the problems solved the issue. I still wonder why this error is caused, in my case I am using assembly definition files.
I wonder if some references I added there caused the problem, but I’d like some expert to say more about this issue
for anyone in future
Delete those scripts
and restore from recycle bin
1 Like
Being more specific, you can only reimport the script file that has the error. Just fixed for me, and it was a script that had nothing to do with GUI.
But it happend when build for android.
I’ve just migrated from Unity 2019 to Unity 2022, and I am getting this error.
I’ve added a public float to an scriptable object and I got this error, so I removed it. Then I added a public float and a public Vector3 to a class (which is used in many prefabs) and I get this error again, I fix it by using [System.NonSerialized] but it seems to me that whenever I add a public variable, Unity doesn’t update the prefabs properly and pops this error.
Is there any way to “clean” the prefabs or solve this issue?
Many thanks.
I’ve managed to fix the issue, it seems some old data or something was left somewhere causing trouble. I did what it is mentioned in this forum and that worked:
So basically:
- 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 …
I hope it helps.
Hi Internet travelers and lurkers.
I got ‘Error building player because script class layout is incompatible between the editor and the player.’ when building my asset bundle.
This happen after upgrading 2022.1.9 → 2022.1.15 some of the official package (InputSystem) also version up in the process, and the culprit module name that came up in error message was those InputSystem!
But I can confirm that my build was ok before the upgrade.
The problem is now fixed,
I thought I would share it here, this are my steps:
- The panic command “Assets → Reimport All” DID NOT WORK.
- I closed the editor. Delete “objs” and “Library” folders inside my project. (Near the Assets folder)
- Wait for full import again. I decided to take a break and read bunches of Manga chapters. It was very productive day!
- After sometime, it is finished. I proceed to build my asset bundle again. and no more error.
Looks like there are lingering script cache or assembly cache somewhere inside that Library folder which could not be cleared even if doing lite recompile or “Reimport All” command.
28 Sep 2022: Small addition
Looks like asset bundle building process is dependent on main player increment building (or whatsoever) building the whole player again first then proceed to build the asset bundle via “AssetBundle Browser” window (it is part of extra package of the same name) seems to work.

In short, if you get such error like above from building asset bundle, rebuild the player again, then proceed with building asset bundle. If all else failed try cleaning “objs” and “Library” as bove.
1 Like
Remove project from Unity Hub, rename Project folder, add project to Unity Hub, run - profit
Reimport the errored script (Right click on script file and click on reimport from drop down menu).