Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug NullRef ScriptableObject inside baked managed component in build in 2022.2.2 unity

Discussion in 'Entity Component System' started by Tony_Max, Jan 20, 2023.

  1. Tony_Max

    Tony_Max

    Joined:
    Feb 7, 2017
    Posts:
    334
    In my project I have managed component which includes
    ScriptableObject
    and
    Material
    . This component baked by using
    Baker.AddComponentObject
    . All works well before 2022.2.2 unity version.

    The problem is:
    ScriptableObject
    is always nullref in build, but other instances isn't null. Problem happens in build only.

    Also problem fixed by adding one another
    ScriptableObject
    to class which now becomes nullref in build and previous one loaded well. So my suggest is there is something wrong with memory layout in 2022.2.2, burst package was updated in this version.
    Note: this workaround requires extra SO be serialized and at least one entity in subscene should have not null instance for this SO (any other can remain null instance)

    Feels like complete magic

    Resolved: Fixed in 2022.2.3 unity version. The thing was
    [FormerlySerializedAs]
    with the same field name.
     
    Last edited: Jan 24, 2023
  2. Laicasaane

    Laicasaane

    Joined:
    Apr 15, 2015
    Posts:
    288
    I had taken the liberty of submitting the bug report for this project.
    Case IN-29284.
     
    Tony_Max likes this.
  3. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,626
    Hmm. Was it just 2022.2.2? I'm pretty sure a similar issue exists in 2022.2.1 (maybe even 2022.2.0)
    I've seen multiple reports of assets assign on managed components and not being included in the build (and can repo it myself.)
     
  4. Anthiese

    Anthiese

    Joined:
    Oct 13, 2013
    Posts:
    72
    I have some similar build-only issues in 2022.2.0f1/1f1/2f1. I thought it was just to do with sub-assets and WeakObjectReference (ECSB-145), but now I’ve also seen similar broken SO deserializations in managed components. In the one case I’ve had to use them, a SO containing a list of SO only deserialized one object properly while leaving the rest null. There’s definitely something screwy going on here.
     
  5. Tony_Max

    Tony_Max

    Joined:
    Feb 7, 2017
    Posts:
    334
    I'm sure it was fine with SO a version before (2022.2.1) because there was issues with builds for my project which I solved and all was fine in build. Right after switching to 2022.2.2 build works wrong because of bad SO thing
     
  6. Tony_Max

    Tony_Max

    Joined:
    Feb 7, 2017
    Posts:
    334
    where can I inspect this? I never submited bug report
     
  7. Laicasaane

    Laicasaane

    Joined:
    Apr 15, 2015
    Posts:
    288
    Unfortunately, only the ones who submit the reports and Unity can see them.
     
    Tony_Max likes this.
  8. Laicasaane

    Laicasaane

    Joined:
    Apr 15, 2015
    Posts:
    288
    This was not resolved by any mean. I've just upgraded to 2022.2.4 and changed a bit of my ScriptableObject setup then the build stops working again.

    But now I know where to look for the bug so I went checking the refs to my ScriptableObjects: all of them are null at runtime.
     
    Tony_Max likes this.
  9. Laicasaane

    Laicasaane

    Joined:
    Apr 15, 2015
    Posts:
    288
    The current workaround is baking SO into blob assets. It's fine for now, but I imagine it can be complicated at the later stage of the project.
     
    Tony_Max likes this.
  10. Laicasaane

    Laicasaane

    Joined:
    Apr 15, 2015
    Posts:
    288
    @Tony_Max I think this bug is fixed in Unity 2022.2.5 according to the changelog
    I've reverted my workaround, made a change to the SO setup, and the build still runs correctly.
     
    Occuros, Anthiese and Tony_Max like this.