using System.Collections;
using System.Collections.Generic;
using System;
using UnityEngine;
using UnityEngine.UI;
public class UIEventManager : MonoBehaviour {
public GameObject btnGameObject;
public GameObject sliderGameObject;
public GameObject dropDownGameObject;
public GameObject toggleGameObject;
// Use this for initialization
void Start () {
btnGameObject.GetComponent<Button>().onClick.AddListener(this.ButtonOnClick);
sliderGameObject.GetComponent<Slider>().onValueChanged.AddListener(this.OnSliderChanged);
dropDownGameObject.GetComponent<Dropdown>().onValueChanged.AddListener(this.OnDropDownChanged);
toggleGameObject.GetComponent<Toggle>().onValueChanged.AddListener(this.OnToggleChanged);
}
void ButtonOnClick()
{
Debug.Log("ButtonOnClick");
}
void OnSliderChanged(float value)
{
Debug.Log("SliderChanged:" + value);
}
void OnDropDownChanged(Int32 value)
{
Debug.Log("DropDownChanged:" + value);
}
void OnToggleChanged(bool value)
{
Debug.Log("ToggleChanged:" + value);
}
// Update is called once per frame
void Update () {
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using System;
//interface
public class UIEventManager2 : MonoBehaviour
//,IPointerDownHandler,IPointerClickHandler,IPointerUpHandler,IPointerEnterHandler,IPointerExitHandler,IBeginDragHandler,IDragHandler,IEndDragHandler,IDropHandler
{
public void OnBeginDrag(PointerEventData eventData)
{
Debug.Log("OnBeginDrag");
}
public void OnDrag(PointerEventData eventData)
{
Debug.Log("OnDrag");
}
public void OnDrop(PointerEventData eventData)
{
Debug.Log("OnDrop");
}
public void OnEndDrag(PointerEventData eventData)
{
Debug.Log("OnEndDrag");
}
public void OnPointerClick(PointerEventData eventData)
{
Debug.Log("OnPointerClick");
}
public void OnPointerDown(PointerEventData eventData)
{
Debug.Log("OnPointerDown");
}
public void OnPointerEnter(PointerEventData eventData)
{
Debug.Log("OnPointerEnter");
}
public void OnPointerExit(PointerEventData eventData)
{
Debug.Log("OnPointerExit");
}
public void OnPointerUp(PointerEventData eventData)
{
Debug.Log("OnPointerUp");
}
}