Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

PhysicsCollider not added when instantiating from prefab

Discussion in 'Entity Component System' started by andynayrb, Dec 19, 2019.

  1. andynayrb

    andynayrb

    Joined:
    Feb 28, 2019
    Posts:
    25
    I have a floor that I convert to an entity and add a physics body and physics shape. In the entity debugger the PhysicsCollider is there. I have a capsule that I have setup the same that I turned into a prefab. In the entity debugger the PhysicsCollider is not there. Everything else that is supposed to be there, is there, just not the Collider. If I don't make it a prefab, it works just fine.

    I am getting the following error, it is pointing to the var prefab line. I am assuming there must be something wrong in the prefab? Is there something special I need to add to the prefab to get it to work? I am probably overlooking something very simple.

    ArgumentNullException: A valid BlobAssetStore must be passed to construct a BlobAssetComputationContext
    Parameter name: blobAssetStore


    var settings = GameObjectConversionSettings.FromWorld(World.DefaultGameObjectInjectionWorld, null);
    var prefab = GameObjectConversionUtility.ConvertGameObjectHierarchy(Prefab, settings);
    var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
    //create player from prefab
    var instance = entityManager.Instantiate(prefab);


    Thanks
     
  2. andynayrb

    andynayrb

    Joined:
    Feb 28, 2019
    Posts:
    25
    I found the solution, or a solution anyhow.
     var settings = GameObjectConversionSettings.FromWorld(World.DefaultGameObjectInjectionWorld, null);


    the null here needs to be replaced with new BlobAssetStore()
     
    SecondCobra, John_MSFT and Jazok like this.