Post by Admin on Jul 16, 2016 4:34:24 GMT
Jan Thomä @derkork Nov 30 2015 17:14
Well I'm doing an RTS and clicking and selecting things in the view is bread and butter for this type of game. For now I have a special MonoBehaviour in the views which holds a reference to the Entity that the view represents. When I click on the view (e.g. a unit) I know which entity was clicked. I probably could decouple this a bit more by giving entities an ID and then referencing the clicked entity by it's ID, however that seems to be more trouble than it's worth right now, especially since there are no fast lookup functions available like "Find Entity with Component IdComponent where value id of IdComponent is X". You can only quickly search for entities having certain components but not for entities having components with certain values. So referring to the entity from the MonoBehaviour is right now the easiest way to do it.
Well I'm doing an RTS and clicking and selecting things in the view is bread and butter for this type of game. For now I have a special MonoBehaviour in the views which holds a reference to the Entity that the view represents. When I click on the view (e.g. a unit) I know which entity was clicked. I probably could decouple this a bit more by giving entities an ID and then referencing the clicked entity by it's ID, however that seems to be more trouble than it's worth right now, especially since there are no fast lookup functions available like "Find Entity with Component IdComponent where value id of IdComponent is X". You can only quickly search for entities having certain components but not for entities having components with certain values. So referring to the entity from the MonoBehaviour is right now the easiest way to do it.