Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

Cant Convert GameObject to Entity in 0.3 version

Discussion in 'Data Oriented Technology Stack' started by Opeth001, Dec 4, 2019.

  1. Opeth001

    Opeth001

    Joined:
    Jan 28, 2017
    Posts:
    627
    Hello Everyone,

    I upgraded my project from entities 0.1 to 0.3.


    my MonoBehaviour code is converting a prefab and instantiating it's entities x times.(got it from ECSSamples)
    Code (CSharp):
    1.  
    2. players = new NativeArray<Entity>(pSkins.Length, Allocator.Persistent);
    3. // Create entity prefab from the Player GameObject Prefab Architype once
    4. var settings = GameObjectConversionSettings.FromWorld(World.DefaultGameObjectInjectionWorld, null); // Error Here
    5. var prefab = GameObjectConversionUtility.ConvertGameObjectHierarchy(clientPlayerPrefabArchitype, settings);
    6. var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
    7.  
    8. // Efficiently instantiate a bunch of entities from the already converted entity prefab
    9. entityManager.Instantiate(prefab, players);
    10.  
    11.  

    The Error:
    Code (CSharp):
    1. ArgumentNullException: A valid BlobAssetStore must be passed to construct a BlobAssetComputationContext
    2. Parameter name: blobAssetStore
    3. Unity.Entities.BlobAssetComputationContext`2[TS,TB]..ctor (Unity.Entities.BlobAssetStore blobAssetStore, System.Int32 initialCapacity, Unity.Collections.Allocator allocator) (at Library/PackageCache/com.unity.entities@0.3.0-preview.4/Unity.Entities.Hybrid/GameObjectConversion/BlobAssetComputationContext.cs:31)
    4. Unity.Physics.Authoring.BeginColliderConversionSystem.OnUpdate () (at Library/PackageCache/com.unity.physics@0.2.5-preview/Unity.Physics.Hybrid/Conversion/BeginColliderConversionSystem.cs:14)
    5. Unity.Entities.ComponentSystem.InternalUpdate () (at Library/PackageCache/com.unity.entities@0.3.0-preview.4/Unity.Entities/ComponentSystem.cs:102)
    6. Unity.Entities.ComponentSystemBase.Update () (at Library/PackageCache/com.unity.entities@0.3.0-preview.4/Unity.Entities/ComponentSystemBase.cs:301)
    7. Unity.Entities.ComponentSystemGroup.OnUpdate () (at Library/PackageCache/com.unity.entities@0.3.0-preview.4/Unity.Entities/ComponentSystemGroup.cs:109)
    8. UnityEngine.DebugLogHandler:LogException(Exception, Object)
    9. Unity.Entities.Conversion.JournalingUnityLogger:LogException(Exception, Object) (at Library/PackageCache/com.unity.entities@0.3.0-preview.4/Unity.Entities.Hybrid/GameObjectConversion/JournalingUnityLogger.cs:50)
    10. UnityEngine.Debug:LogException(Exception)
    11. Unity.Debug:LogException(Exception) (at Library/PackageCache/com.unity.entities@0.3.0-preview.4/Unity.Entities/Stubs/Unity/Debug.cs:19)
    12. Unity.Entities.ComponentSystemGroup:OnUpdate() (at Library/PackageCache/com.unity.entities@0.3.0-preview.4/Unity.Entities/ComponentSystemGroup.cs:113)
    13. Unity.Entities.ComponentSystem:InternalUpdate() (at Library/PackageCache/com.unity.entities@0.3.0-preview.4/Unity.Entities/ComponentSystem.cs:102)
    14. Unity.Entities.ComponentSystemBase:Update() (at Library/PackageCache/com.unity.entities@0.3.0-preview.4/Unity.Entities/ComponentSystemBase.cs:301)
    15. Unity.Entities.GameObjectConversionUtility:Convert(World) (at Library/PackageCache/com.unity.entities@0.3.0-preview.4/Unity.Entities.Hybrid/GameObjectConversion/GameObjectConversionUtility.cs:147)
    16. Unity.Entities.GameObjectConversionUtility:ConvertGameObjectHierarchy(GameObject, GameObjectConversionSettings) (at Library/PackageCache/com.unity.entities@0.3.0-preview.4/Unity.Entities.Hybrid/GameObjectConversion/GameObjectConversionUtility.cs:229)
     
    TZ- and StivenUnity like this.
  2. Opeth001

    Opeth001

    Joined:
    Jan 28, 2017
    Posts:
    627
    it's working now by changing this part:
    Code (CSharp):
    1.  
    2. var settings = GameObjectConversionSettings.FromWorld(World.DefaultGameObjectInjectionWorld, null);
    3.  
    4. to
    5.  
    6. var settings = GameObjectConversionSettings.FromWorld(World.DefaultGameObjectInjectionWorld, new BlobAssetStore());
     
  3. Opeth001

    Opeth001

    Joined:
    Jan 28, 2017
    Posts:
    627
    im using Entities 0.4 and this workaround dont works correctly for some android devices,(the player goes under the ground)
     
    aVaKus likes this.
unityunity