I made a script that brings a UGUI element to the front:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class MoveToFront : UIBehaviour, IPointerDownHandler {
public void OnPointerDown( PointerEventData eventData ) {
Debug.Log("Move to front");
transform.SetAsLastSibling(); //move to front
eventData.Use();
}
}
This works beautifully if I put it on an image, but if I put it on an empty gameObject then it doesn’t work. What do I have to add to make an empty gameObject catch the event?