Spent a while today just building and rebuilding my project trying to figure out why my UI stopped working randomly and instead resulted in the following errors:
The referenced script (UnityEngine.UIElements.ThemeStyleSheet) on this Behaviour is missing!
The referenced script on this Behaviour (Game Object '<null>') is missing!
A scripted object (probably UnityEngine.UIElements.ThemeStyleSheet?) has a different serialization layout when loading. (Read 52 bytes but expected 124 bytes)
Did you #ifdef UNITY_EDITOR a section of your serialized properties in any of your scripts?
The referenced script (UnityEngine.UIElements.PanelSettings) on this Behaviour is missing!
The referenced script on this Behaviour (Game Object '<null>') is missing!
A scripted object (probably UnityEngine.UIElements.PanelSettings?) has a different serialization layout when loading. (Read 40 bytes but expected 192 bytes)
Did you #ifdef UNITY_EDITOR a section of your serialized properties in any of your scripts?
The referenced script (UnityEngine.UIElements.ThemeStyleSheet) on this Behaviour is missing!
The referenced script on this Behaviour (Game Object '<null>') is missing!
A scripted object (probably UnityEngine.UIElements.ThemeStyleSheet?) has a different serialization layout when loading. (Read 40 bytes but expected 69828 bytes)
Did you #ifdef UNITY_EDITOR a section of your serialized properties in any of your scripts?
The referenced script (UnityEngine.UIElements.UIDocument) on this Behaviour is missing!
The referenced script on this Behaviour (Game Object 'UIDocument') is missing!
A scripted object (probably UnityEngine.UIElements.UIDocument?) has a different serialization layout when loading. (Read 32 bytes but expected 72 bytes)
Did you #ifdef UNITY_EDITOR a section of your serialized properties in any of your scripts?
Well, it’s because IL2CPP scripting backend breaks UI Toolkit on the Alpha version. Mono build however does not have a problem.
Easy fix, go back to Mono scripting backend until maybe a fix. Or disable the UI. Both work depending on the use case.
I didnt look too far into the package and actually attempt to fix this. Seems simplistic enough, check if the various serializable fields are making its way into the build. But I wasted enough time today building my project over and over again.
Edit: Actually, I think it’s because of IL2CPP’s managed stripping level. I’ll see about trying to include random assemblies in the build to prevent IL2CPP from stripping away required scripts.