When I build my Windows game I get a lot of the following errors:
The referenced script (Unknown) on this Behaviour is missing!
A scripted object (probably Animations.AnimationSequence?) has a different serialization layout when loading. (Read 44 bytes but expected 296 bytes)
Did you #ifdef UNITY_EDITOR a section of your serialized properties in any of your scripts?```
However, I have no idea where they come from, as I have no similar errors in the editor. I get the errors both when I #ifdef #endif my Editor code and when I don't, and I've run a script to check for "ghost" GameObject as described in [this article](https://gigadrillgames.com/2020/03/19/finding-missing-scripts-in-unity/) but it didn't find any. I've double checked that my Test Assemblies' Platform is set to Editor only.
As part of finding the issue, I made an empty scene and made a build with it. No errors.
I added a Mover script and ran a build. Got a bunch of errors.
Then I removed all the code from the Mover script and ran the build. No errors.
After slowly re-adding stuff to the Mover script, I found out that I only get these errors when I have *public* or *[SerializeField] private* variables in my script. *private* variables are fine.
I'm really scratching my head at this - why wouldn't it be okay to add those variables?
Here's the complete class with everything that causes an error commented out: https://hatebin.com/hliqdrrqvq
Any help would be hugely appreciated!