Hello!
For example I have a city builder game. I have one building that has several phases of construction (eg 3). For each stage there is a separate model.
Example Game Objects Structure:
- My Building (BuildingMonoBehavior)
- - State1
- - State2
- - State3
I need to catch the click (and hover for tooltips) event for this building. But the Game Object "My Building" is a logical, and the Game Objects "State N" are the actual meshes with colliders. Can simultaneously be active only one State.
It is more logical to handle all the operations on the "BuildingMonoBehavior" and catch clicks there, too. But the events of the camera, we can only catch in "State" scripts.
How best to organize the relationship?
What comes to my mind, it's add on every state (the actual mesh object) collider and script (StateMonoBehavior) in which to write a delegate that will be called in the event OnClick. And in the root object (BuildingMonoBehavior) to subscribe to the delegates of all the states and make the necessary work.
To me it's a bit like working with lists and its elements.
But perhaps there is another solution in NGUI?
In Flash can be subscribed at the object and catch the pop-up (bubble) events such as.
Thanks!