UserDefineButton.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. /****************************************************************************
  2. * Copyright 2019 Nreal Techonology Limited. All rights reserved.
  3. *
  4. * This file is part of NRSDK.
  5. *
  6. * https://www.nreal.ai/
  7. *
  8. *****************************************************************************/
  9. using System;
  10. using UnityEngine;
  11. using UnityEngine.EventSystems;
  12. namespace NRKernal.NRExamples
  13. {
  14. /// <summary> A user define button. </summary>
  15. public class UserDefineButton : MonoBehaviour, IPointerClickHandler
  16. {
  17. /// <summary> The on click. </summary>
  18. public Action<string> OnClick;
  19. /// <summary> <para>Use this callback to detect clicks.</para> </summary>
  20. /// <param name="eventData"> Current event data.</param>
  21. public void OnPointerClick(PointerEventData eventData)
  22. {
  23. if (OnClick != null)
  24. {
  25. OnClick(gameObject.name);
  26. }
  27. }
  28. }
  29. }