Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug UI Toolkit (built in, no package) fails to build on 2021.2 Alpha with IL2CPP.

Discussion in 'UI Toolkit' started by Kmsxkuse, Apr 14, 2021.

  1. Kmsxkuse

    Kmsxkuse

    Joined:
    Feb 15, 2019
    Posts:
    305
    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:

    Code (CSharp):
    1. The referenced script (UnityEngine.UIElements.ThemeStyleSheet) on this Behaviour is missing!
    2.  
    3. The referenced script on this Behaviour (Game Object '<null>') is missing!
    4.  
    5. A scripted object (probably UnityEngine.UIElements.ThemeStyleSheet?) has a different serialization layout when loading. (Read 52 bytes but expected 124 bytes)
    6. Did you #ifdef UNITY_EDITOR a section of your serialized properties in any of your scripts?
    7.  
    8. The referenced script (UnityEngine.UIElements.PanelSettings) on this Behaviour is missing!
    9.  
    10. The referenced script on this Behaviour (Game Object '<null>') is missing!
    11.  
    12. A scripted object (probably UnityEngine.UIElements.PanelSettings?) has a different serialization layout when loading. (Read 40 bytes but expected 192 bytes)
    13. Did you #ifdef UNITY_EDITOR a section of your serialized properties in any of your scripts?
    14.  
    15. The referenced script (UnityEngine.UIElements.ThemeStyleSheet) on this Behaviour is missing!
    16.  
    17. The referenced script on this Behaviour (Game Object '<null>') is missing!
    18.  
    19. A scripted object (probably UnityEngine.UIElements.ThemeStyleSheet?) has a different serialization layout when loading. (Read 40 bytes but expected 69828 bytes)
    20. Did you #ifdef UNITY_EDITOR a section of your serialized properties in any of your scripts?
    21.  
    22. The referenced script (UnityEngine.UIElements.UIDocument) on this Behaviour is missing!
    23.  
    24. The referenced script on this Behaviour (Game Object 'UIDocument') is missing!
    25.  
    26. A scripted object (probably UnityEngine.UIElements.UIDocument?) has a different serialization layout when loading. (Read 32 bytes but expected 72 bytes)
    27. 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.
     
    Last edited: Apr 14, 2021
  2. antoine-unity

    antoine-unity

    Unity Technologies

    Joined:
    Sep 10, 2015
    Posts:
    771
    Would you mind submitting a bug from Unity with the steps to reproduce this?
     
  3. Midiphony-panda

    Midiphony-panda

    Joined:
    Feb 10, 2020
    Posts:
    242