This is more a question about architecture. Not sure if there's a right or wrong:
Let's assume I have some gameobjects:
- GUI: A menu containing some elements like "Go to position". It's opened when right clicking in the game
- Main Camera
- Characters: Characters in the game which can be controlled by the player
Now I was thinking about the following scenarios:
- A character is clicked. It's highlighted yellow. This should definitely be done in the script of the character.
- When a character is highlighted (or selected) and the right mouse button is clicked, the GUI will be shown. Where does this have to be implemented when talking about clean code? In the character? But then the character has to know about the GUI. I'm not sure if this is clean. In the GUI? Then then the GUI has to know if a character was highlighted (or selected). Doesn't feel clean too.