The documentation is a bit unclear on this (or maybe I am just not read ing it well enough), but can interfaces in the EventSystem be used for things that at not in the Canvas?
My game requires that I be able to select gameobjects. When a game object is selected, it will typically display a menu.
I was going to use a custom input manager class to capture raycasts from the screen, see what was hit, then display the correct menu based on that. However, I figured before I start going down that road, I should see if I can leverage what Unity already provides for event management.
I want to know if it is possible to do this (assume this script is attached to a normal [non-UI] gameobject):
public class Block : MonoBehaviour, IPointerClickHandler {
public void OnPointerClick(PointerEventData eventData) {
Debug.Log("Block " + gameObject.GetInstanceID() + " was clicked");
}
}
I would expect that whenever I click on this gameobject in the scene, the message will be logged. It does not though.
I’m assuming you CAN’T do this, but I wanted to be sure I am not just doing something incorrectly.