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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    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.