johnhattan

Remotely-clickable Button Component in Unity

Jan 24th, 2017
397
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.32 KB | None | 0 0
  1. using System.Collections;
  2.  
  3. using UnityEngine;
  4. using UnityEngine.EventSystems;
  5. using UnityEngine.UI;
  6.  
  7. public class UIButtonRemote : MonoBehaviour
  8. {
  9.     public void OnClick()
  10.     {
  11.         EventSystem.current.SetSelectedGameObject(gameObject);  // select me
  12.         gameObject.GetComponent<Button>().onClick.Invoke(); // and click me
  13.     }
  14. }
Advertisement
Add Comment
Please, Sign In to add comment