Search Unity

how to use 2d.entities to render a sprite

Discussion in 'Graphics for ECS' started by zhoutaosheng-elex, Jul 21, 2021.

  1. zhoutaosheng-elex

    zhoutaosheng-elex

    Joined:
    Mar 31, 2021
    Posts:
    12
    I create a sprite and add ConvertToEntity to the sprite, it looks like as follow
    upload_2021-7-21_16-51-31.png
    I run the scene, it gives me the error as follow

    Code (CSharp):
    1. ArgumentException: A component with type:EditorRenderData has not been added to the entity.
    2. Unity.Entities.EntityComponentStore.AssertEntityHasComponent (Unity.Entities.Entity entity, Unity.Entities.ComponentType componentType) (at Library/PackageCache/com.unity.entities@0.17.0-preview.41/Unity.Entities/EntityComponentStoreDebug.cs:281)
    3. Unity.Entities.EntityComponentStore.AssertEntityHasComponent (Unity.Entities.Entity entity, System.Int32 componentType) (at Library/PackageCache/com.unity.entities@0.17.0-preview.41/Unity.Entities/EntityComponentStoreDebug.cs:287)
    4. Unity.Entities.EntityDataAccess.GetSharedComponentData[T] (Unity.Entities.Entity entity) (at Library/PackageCache/com.unity.entities@0.17.0-preview.41/Unity.Entities/EntityDataAccess.cs:1195)
    5. Unity.Entities.EntityManager.GetSharedComponentData[T] (Unity.Entities.Entity entity) (at Library/PackageCache/com.unity.entities@0.17.0-preview.41/Unity.Entities/EntityManagerAccessComponentData.cs:215)
    6. Unity.U2D.Entities.SpriteRendererHybridRendering+<>c__DisplayClass_OnUpdate_LambdaJob0.OriginalLambdaBody (Unity.Entities.Entity e, System.Int32 entityInQueryIndex, Unity.U2D.Entities.Renderer2D& renderer2D, Unity.U2D.Entities.SpriteRenderer& spriteRenderer, Unity.Transforms.LocalToWorld& localToWorld) (at Library/PackageCache/com.unity.2d.entities@0.32.0-preview.5/SpriteRenderer/Unity.2D.Entities.SpriteRenderer.Hybrid/SpriteRendererHybridRendering.cs:58)
    7. Unity.U2D.Entities.SpriteRendererHybridRendering+<>c__DisplayClass_OnUpdate_LambdaJob0.IterateEntities (Unity.Entities.ArchetypeChunk& chunk, Unity.U2D.Entities.SpriteRendererHybridRendering+<>c__DisplayClass_OnUpdate_LambdaJob0+LambdaParameterValueProviders+Runtimes& runtimes) (at <0823578e72f2458885415ed590a304e9>:0)
    8. Unity.U2D.Entities.SpriteRendererHybridRendering+<>c__DisplayClass_OnUpdate_LambdaJob0.Execute (Unity.Entities.ArchetypeChunk chunk, System.Int32 chunkIndex, System.Int32 firstEntityIndex) (at <0823578e72f2458885415ed590a304e9>:0)
    9. Unity.Entities.JobChunkExtensions.RunWithoutJobs[T] (T& jobData, Unity.Entities.ArchetypeChunkIterator& chunkIterator) (at Library/PackageCache/com.unity.entities@0.17.0-preview.41/Unity.Entities/IJobChunk.cs:182)
    10. Unity.U2D.Entities.SpriteRendererHybridRendering+<>c__DisplayClass_OnUpdate_LambdaJob0.RunWithoutJobSystem (Unity.Entities.ArchetypeChunkIterator* archetypeChunkIterator, System.Void* jobData) (at <0823578e72f2458885415ed590a304e9>:0)
    11. Unity.Entities.InternalCompilerInterface.RunJobChunk[T] (T& jobData, Unity.Entities.EntityQuery query, Unity.Entities.InternalCompilerInterface+JobChunkRunWithoutJobSystemDelegate functionPointer) (at Library/PackageCache/com.unity.entities@0.17.0-preview.41/Unity.Entities/CodeGeneratedJobForEach/LambdaJobDescription.cs:390)
    12. Unity.U2D.Entities.SpriteRendererHybridRendering.OnUpdate () (at Library/PackageCache/com.unity.2d.entities@0.32.0-preview.5/SpriteRenderer/Unity.2D.Entities.SpriteRenderer.Hybrid/SpriteRendererHybridRendering.cs:45)
    13. Unity.Entities.SystemBase.Update () (at Library/PackageCache/com.unity.entities@0.17.0-preview.41/Unity.Entities/SystemBase.cs:412)
    14. Unity.Entities.ComponentSystemGroup.UpdateAllSystems () (at Library/PackageCache/com.unity.entities@0.17.0-preview.41/Unity.Entities/ComponentSystemGroup.cs:472)
    15. UnityEngine.Debug:LogException(Exception)
    16. Unity.Debug:LogException(Exception) (at Library/PackageCache/com.unity.entities@0.17.0-preview.41/Unity.Entities/Stubs/Unity/Debug.cs:19)
    17. Unity.Entities.ComponentSystemGroup:UpdateAllSystems() (at Library/PackageCache/com.unity.entities@0.17.0-preview.41/Unity.Entities/ComponentSystemGroup.cs:477)
    18. Unity.Entities.ComponentSystemGroup:OnUpdate() (at Library/PackageCache/com.unity.entities@0.17.0-preview.41/Unity.Entities/ComponentSystemGroup.cs:417)
    19. Unity.Entities.ComponentSystem:Update() (at Library/PackageCache/com.unity.entities@0.17.0-preview.41/Unity.Entities/ComponentSystem.cs:114)
    20. Unity.Entities.DummyDelegateWrapper:TriggerUpdate() (at Library/PackageCache/com.unity.entities@0.17.0-preview.41/Unity.Entities/ScriptBehaviourUpdateOrder.cs:333)
    21.  
    So, what's the right way to use 2d.entities?
     
  2. dredywko

    dredywko

    Joined:
    Sep 8, 2020
    Posts:
    13
    Yeah, I laso wnat to clarify some points about com.unity.2d.entities:
    1) Is this package will works without project tiny package but with entities or not?
    2) If not - does unity team planning to add some easy, built-in way to work with 2D to ECS and converting sprites to ECS?
     
  3. VincentBreysse

    VincentBreysse

    Unity Technologies

    Joined:
    May 31, 2021
    Posts:
    27
    From what I can tell, this is supposed to work. So it's likely either your project that is not configured correctly, or a bug.
    In the latter case, please report the bug with a repro case so that it can be investigated.
    I would suggest posting this to the Project Tiny forum section to get a well-rounded answer. They own 2D entities.
    Also, hybrid renderer does not support sprite rendering, and it's not planned for the moment.
     
    Last edited: Aug 10, 2021
  4. Djo_krd

    Djo_krd

    Joined:
    Sep 6, 2017
    Posts:
    31
    So, is somebody success with com.unity.2d.entities in DOTS project without Tiny packages?