You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey, I've been using DefaultEcs for a while now and updated from 0.15.2 to 0.17.0 recently.
It looks like it is no longer possible to remove an added component in a ComponentAdded or ComponentChanged subscriber. I did some digging into the changes made between those versions, and it looks like the issue is caused by a change made in version 0.16.0 to the Entity.Set method.
The Entity.Set function was changed from using the component argument on line 184 in 0.15.2 to using a call to Entity.Get instead on line 89 in 0.16.0.
Is there any way you could include a Entity.Has check before using Entity.Get here? This issue will block my upgrade path of this great library.
You can reproduce this by creating a subscriber on ComponentAdded, and removing the component being added from in that subscriber.
publicclassComponentRemover{publicComponentRemover(Worldworld){
world.SubscribeComponentAdded(ValidateComponent);}privatevoidValidateComponent(inEntityentity,inMyComponentcomponent){// maybe some validation happens here and we need to remove the component...
entity.Remove<MyComponent>();// ERROR: this line will produce a IndexOutOfRangeException}}
Something like below or if you have a better method:
The text was updated successfully, but these errors were encountered:
dkominek
changed the title
No longer able to remove an added component from WhenAdded or WhenChanged subscriber
No longer able to remove an added component from ComponentAdded or ComponentChanged subscriber
Dec 13, 2021
Really sorry I took this long to fix this, start of the year has been as crazy as the end of the previous one ^^" I hope I'll get some free time more frequently!
Hey, I've been using DefaultEcs for a while now and updated from 0.15.2 to 0.17.0 recently.
It looks like it is no longer possible to remove an added component in a ComponentAdded or ComponentChanged subscriber. I did some digging into the changes made between those versions, and it looks like the issue is caused by a change made in version 0.16.0 to the Entity.Set method.
The Entity.Set function was changed from using the component argument on line 184 in 0.15.2 to using a call to Entity.Get instead on
line 89 in 0.16.0.
Is there any way you could include a Entity.Has check before using Entity.Get here? This issue will block my upgrade path of this great library.
You can reproduce this by creating a subscriber on ComponentAdded, and removing the component being added from in that subscriber.
Something like below or if you have a better method:
The text was updated successfully, but these errors were encountered: