Search Unity

Resolved Try using subscene in Android player but failed

Discussion in 'Entity Component System' started by YakShaver_dc, Jun 10, 2021.

  1. YakShaver_dc

    YakShaver_dc

    Joined:
    Mar 27, 2019
    Posts:
    29
    I created a project to do some tests about subscene (using Universal RP). I wrote a custom bootstrap to create a world for loading subscene and later DefaultGameObjectInjectionWorld move the entites from it. Everything goes fine in editor but it doesn't work in android player. I found the exception by adb.
    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2.   at Unity.Entities.TypeManager.GetSystems (Unity.Entities.WorldSystemFilterFlags filterFlags, Unity.Entities.WorldSystemFilterFlags requiredFlags) [0x0002a] in <4689184a8a0f453797aecd147541936e>:0
    3.   at Unity.Entities.DefaultWorldInitialization.GetAllSystems (Unity.Entities.WorldSystemFilterFlags filterFlags, System.Boolean requireExecuteAlways) [0x00001] in <4689184a8a0f453797aecd147541936e>:0
    4.   at CustomBootstrap.Initialize (System.String defaultWorldName) [0x00001] in E:\Projects\SubsceneTest5\Assets\Scripts\CustomBootstrap.cs:29
    5.   at Unity.Entities.DefaultWorldInitialization.Initialize (System.String defaultWorldName, System.Boolean editorWorld) [0x00019] in <4689184a8a0f453797aecd147541936e>:0
    6.   at Unity.Entities.AutomaticWorldBootstrap.Initialize () [0x00001] in E:\Projects\SubsceneTest5\Library\PackageCache\com.unity.entities@0.16.0-preview.21\Unity.Entities.Hybrid\Injection\AutomaticWorldBootstrap.cs:15
    The exception is occurred when try to get the list of all default systems.
    Code (CSharp):
    1. public class CustomBootstrap : ICustomBootstrap
    2. {
    3.      ...
    4.  
    5.     public bool Initialize(string defaultWorldName)
    6.     {
    7.        // Exception is the line below
    8.         var systems = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Default);
    9.      }
    10.       ...
    11. }
    12.  
    I used BuildConfiguration, the config is here.
    企业微信截图_16233240145769.png

    Unity 2020.1.4.f1
    Entities 0.16.0-preview.21
    Hybrid Render 0.10.0-preview.21
    Platforms Android 0.9.0-preview.9
    Universal RP 9.0.0-preview.72

    Does anyone know why this is happening?
     
  2. YakShaver_dc

    YakShaver_dc

    Joined:
    Mar 27, 2019
    Posts:
    29
    Finally, i found the way to fix it. Before calling DefaultWorldInitialization, should initialize
    DefaultGameObjectInjectionWorld first.
     
    Last edited: Jun 11, 2021