Closed atkdefender closed 3 years ago
It will not sometimes indicate an error, but always. You try to access data that does not exist.
Tip: If you use ReactiveSystem
s you can also set the filter method correctly in advance. Like in this example here:
https://github.com/sschmid/Match-One/blob/master/Assets/Features/Board/Systems/FallSystem.cs
The filter also checks if it is a piece before the execute is called.
How would you wish what would happen if the component did not exist on the entity?
It will not sometimes indicate an error, but always. You try to access data that does not exist.
Tip: If you use
ReactiveSystem
s you can also set the filter method correctly in advance. Like in this example here: https://github.com/sschmid/Match-One/blob/master/Assets/Features/Board/Systems/FallSystem.cs The filter also checks if it is a piece before the execute is called.How would you wish what would happen if the component did not exist on the entity?
Something like "entity.component?.value=...", if it doesn't cause error, that will be great.
I know the reason now. I allways use entitas and coroutine together. When the coroutine ends, some entities is don't have that component already. Maybe I should program the "EntityGroup", instead of one "Entity".
C# in unity
Without "if(entity.hasComponent)", "entity.component" sometimes cause a error. But it make my code to long.