Search Unity

[Subscene] Build an apk but cann't see the subscene because MissingPropertyBagException for Light

Discussion in 'Entity Component System' started by YakShaver_dc, Sep 1, 2020.

  1. YakShaver_dc

    YakShaver_dc

    Joined:
    Mar 27, 2019
    Posts:
    29
    I create an scene which has two subscenes, it works fine in editor. Then I build an apk via new BuildSettings, but when run it, there is an error in log:

    "Error when loading 'AsyncLoadSceneJob ....‘, Unity.Properties.MissingPropertyBagException: No PropertyBag was found for Type=[UnityEngine.Light]. Please make sure all types are declared ahead of time using [GeneratePropertyBagAttribute], [GeneratePropertyBagsForTypeAttribute] or [GeneratePropertyBagsForTypesQualifiedWithAttribute]"

    Unity version: 2019.3.7f1
    Entities:0.10.0
    Hybrid Renderer:0.5.0

    Something about UnityEngine.Light is wrong in android package. It has been proved when I delete all lights in scene and the error is gone. So, could anyone help me to fix this issue?
     
    Last edited: Sep 1, 2020
  2. nicolasgramlich

    nicolasgramlich

    Joined:
    Sep 21, 2017
    Posts:
    231
    Iirc you can't have lights in Subscenes. I'm currently just disabling them (for me it's luckily just some minor visual effect). Afaik the only way is to keep it in the main scene and do Convert and Inject GameObject.
     
    Last edited: Sep 2, 2020
  3. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,759
    They actually work /fine/.

    Hybrid renderer has a light conversion system, that just adds them as hybrid components

    Code (CSharp):
    1.     [WorldSystemFilter(WorldSystemFilterFlags.HybridGameObjectConversion)]
    2.     public class LightConversionSystem : GameObjectConversionSystem
    3.     {
    4.         protected override void OnUpdate()
    5.         {
    6. #if HDRP_7_0_0_OR_NEWER || !HDRP_7_0_0_OR_NEWER
    7.             Entities.ForEach((Light light) =>
    8.             {
    9.                 AddHybridComponent(light);
    10.                 ConfigureEditorRenderData(GetPrimaryEntity(light), light.gameObject, true);
    11.             });
    12. #endif
    13.  
    14. #if HDRP_7_0_0_OR_NEWER
    15.             Entities.ForEach((HDAdditionalLightData light) =>
    16.             {
    17.                 AddHybridComponent(light);
    18.             });
    19. #endif
    20.  
    21. #if URP_7_0_0_OR_NEWER
    22.             Entities.ForEach((UniversalAdditionalLightData vfx) =>
    23.             {
    24.                 AddHybridComponent(vfx);
    25.             });
    26. #endif
    27.         }
    28.     }
    Causes issues when you open a converted subscene in the editor with hdrp by throwing errors about 2 directional lights in scene.
     
    Last edited: Sep 1, 2020
    nicolasgramlich likes this.
  4. YakShaver_dc

    YakShaver_dc

    Joined:
    Mar 27, 2019
    Posts:
    29
    Glad to know this. But I need to find a way to make lights work in subscene since they are different between these subscenes.
     
  5. YakShaver_dc

    YakShaver_dc

    Joined:
    Mar 27, 2019
    Posts:
    29
    Thank you. Should I put these code in my project? I have try, it seems nothing has been done and cann't break the codes in Visual studio.
     
  6. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,759
    you need to update, you're 3 versions behind on hybrid renderer and 5 versions behind on entities

    and they probably only work in v2 of hybrid renderer (2020.1+)
     
  7. YakShaver_dc

    YakShaver_dc

    Joined:
    Mar 27, 2019
    Posts:
    29
    Thank you again, I double checked my packageManager, my Entities is version preview.6 - 0.10.0, Hybrid renderer is version preview.6 - 0.5.0, both of them are up to date. But yes, my Unity is 2019.3.7f1, not 2020.1+, so updating the Unity is the only way to use Subscene properly?
     
  8. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,759
    It's because your unity is old

    Latest versions are
    Entities: 0.14.0-preview.8
    Hybrid Renderer: 0.8.0-preview.18
     
  9. YakShaver_dc

    YakShaver_dc

    Joined:
    Mar 27, 2019
    Posts:
    29
    Oh, thank you very much. The Dots has been improved a lot than what I known since I always use Unity 2019.