Antoshidza / NSprites-Foundation

Basic assets for working with NSprites package
MIT License
65 stars 17 forks source link

destroy the child entity #10

Closed 980538137 closed 10 months ago

980538137 commented 11 months ago

Add an Entity to the parent Entity, When I destroy the child Entity Program error,How Can i destroy the child entity from parent Entity

System.ArgumentException: The entity does not exist. This Exception was thrown from a job compiled with Burst, which has limited exception support. 0x00007ffde165c586 (e66c59c764169f741423df1c419b5a2) Unity.Entities.EntityComponentStore.AssertEntityHasComponent (at D:/work/client_Survivor/Library/PackageCache/com.unity.burst@1.8.7/.Runtime/Library/PackageCache/com.unity.entities@1.0.11/Unity.Entities/EntityComponentStoreDebug.cs:338) 0x00007ffde16aaed2 (e66c59c764169f741423df1c419b5a2) Unity.Entities.ComponentLookup1<NSprites.LocalToWorld2D>.get_Item (at D:/work/client_Survivor/Library/PackageCache/com.unity.burst@1.8.7/.Runtime/Library/PackageCache/com.unity.entities@1.0.11/Unity.Entities/Iterators/ComponentLookup.cs:235) 0x00007ffde16a9d48 (e66c59c764169f741423df1c419b5a2) NSprites.LocalToWorldSystem2D.ComputeChildLocalToWorldJob.ChildLocalToWorldFromTransformMatrix (at D:/work/client_Survivor/Assets/NSprites-Foundation/Transform2D/Systems/LocalToWorldSystem.cs:98) 0x00007ffde16aa28c (e66c59c764169f741423df1c419b5a2) NSprites.LocalToWorldSystem2D.ComputeChildLocalToWorldJob.ChildLocalToWorldFromTransformMatrix (at D:/work/client_Survivor/Assets/NSprites-Foundation/Transform2D/Systems/LocalToWorldSystem.cs:103) 0x00007ffde16aa7e8 (e66c59c764169f741423df1c419b5a2) NSprites.LocalToWorldSystem2D.ComputeChildLocalToWorldJob.Execute (at D:/work/client_Survivor/Assets/NSprites-Foundation/Transform2D/Systems/LocalToWorldSystem.cs:122) 0x00007ffde16abc00 (e66c59c764169f741423df1c419b5a2) Unity.Entities.JobChunkExtensions.JobChunkProducer1.ExecuteInternal (at D:/work/client_Survivor/Library/PackageCache/com.unity.burst@1.8.7/.Runtime/Library/PackageCache/com.unity.entities@1.0.11/Unity.Entities/IJobChunk.cs:400) 0x00007ffde16a97f6 (e66c59c764169f741423df1c419b5a2) c6b5edfca1a757b312a8fd6185424bf0 0x00007ff643351ddc (Unity) ExecuteJob 0x00007ff643352144 (Unity) ExecuteJobCopyData 0x00007ff643352e5f (Unity) ForwardJobForEachToManaged 0x00007ff64334f02e (Unity) ujob_execute_job 0x00007ff64334e4e4 (Unity) lane_guts 0x00007ff643351044 (Unity) worker_thread_routine 0x00007ff643580507 (Unity) Thread::RunThreadWrapper 0x00007ffe510326ad (KERNEL32) BaseThreadInitThunk 0x00007ffe52b6aa68 (ntdll) RtlUserThreadStart

Antoshidza commented 11 months ago

@utkucnay need your help here

Antoshidza commented 11 months ago

Ok, seems there will no help. I'll look into this. Obviously such functionality need unit test.

Also I want to tell 2 things:

Antoshidza commented 11 months ago

I have plans to strip off 2D transforms. Will do this in next update very soon.

980538137 commented 11 months ago

I solved this problem by removing the Parent and Parent2D components before destroying the ChildEntity, and then destroying the ChildEntity in another system running behind the ParentSystem2D

Antoshidza commented 11 months ago

Would you mind to make a pull request?

980538137 commented 11 months ago

This is only a modification at the business level. There is no problem at the NSpriteFounddation framework level.

Antoshidza commented 11 months ago

I solved this problem by removing the Parent and Parent2D components before destroying the ChildEntity, and then destroying the ChildEntity in another system running behind the ParentSystem2D

Do you think this shouldn't be done automatically?