Remotely-clickable Button Component in Unity
using System.Collections;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class UIButtonRemote : MonoBehaviour
{
public void OnClick()
{
EventSystem.current.SetSelectedGameObject(gameObject); // select me
gameObject.GetComponent<Button>().onClick.Invoke(); // and click me
}
}
Comments