Post by Admin on Jul 16, 2016 4:44:26 GMT
Maxim Zaks @mzaks Dec 03 2015 22:30
@dmitriyl sorry for the late reply. The only problem that can occur with your solution is:
What happens if you destroy an entity. If it implies that you also directly or even before that destroy the game object than you are good.
But to be sure you should call e.Retain(this) in connectGameObjectAndEntity and than have an OnDestroy method in the Behaviour where you do entity.Release(this)
If you don't do Retain it could happen that the entity was destroyed and is already reincarnated as something else.
If you don't do Release the entity will never be reused again and so you have a tiny memory leak.
@dmitriyl sorry for the late reply. The only problem that can occur with your solution is:
What happens if you destroy an entity. If it implies that you also directly or even before that destroy the game object than you are good.
But to be sure you should call e.Retain(this) in connectGameObjectAndEntity and than have an OnDestroy method in the Behaviour where you do entity.Release(this)
If you don't do Retain it could happen that the entity was destroyed and is already reincarnated as something else.
If you don't do Release the entity will never be reused again and so you have a tiny memory leak.