31 lines
520 B
C#
31 lines
520 B
C#
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
|
|
namespace UIWidgets
|
|
{
|
|
public class BringToFront : MonoBehaviour, IPointerDownHandler, IEventSystemHandler
|
|
{
|
|
[SerializeField]
|
|
public bool WithParents;
|
|
|
|
public virtual void OnPointerDown(PointerEventData eventData)
|
|
{
|
|
ToFront();
|
|
}
|
|
|
|
public virtual void ToFront()
|
|
{
|
|
ToFront(base.transform);
|
|
}
|
|
|
|
private void ToFront(Transform obj)
|
|
{
|
|
obj.SetAsLastSibling();
|
|
if (WithParents && obj.parent != null)
|
|
{
|
|
ToFront(obj.parent);
|
|
}
|
|
}
|
|
}
|
|
}
|