123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- using System;
- using UnityEngine;
- [AddComponentMenu("NGUI/Internal/Event Listener")]
- public class UIEventListener : MonoBehaviour
- {
- private void OnSubmit()
- {
- if (this.onSubmit != null)
- {
- this.onSubmit(base.gameObject);
- }
- }
- private void OnClick()
- {
- if (this.onClick != null)
- {
- this.onClick(base.gameObject);
- }
- }
- private void OnDoubleClick()
- {
- if (this.onDoubleClick != null)
- {
- this.onDoubleClick(base.gameObject);
- }
- }
- private void OnHover(bool isOver)
- {
- if (this.onHover != null)
- {
- this.onHover(base.gameObject, isOver);
- }
- }
- private void OnPress(bool isPressed)
- {
- if (this.onPress != null)
- {
- this.onPress(base.gameObject, isPressed);
- }
- }
- private void OnSelect(bool selected)
- {
- if (this.onSelect != null)
- {
- this.onSelect(base.gameObject, selected);
- }
- }
- private void OnScroll(float delta)
- {
- if (this.onScroll != null)
- {
- this.onScroll(base.gameObject, delta);
- }
- }
- private void OnDragStart()
- {
- if (this.onDragStart != null)
- {
- this.onDragStart(base.gameObject);
- }
- }
- private void OnDrag(Vector2 delta)
- {
- if (this.onDrag != null)
- {
- this.onDrag(base.gameObject, delta);
- }
- }
- private void OnDragOver()
- {
- if (this.onDragOver != null)
- {
- this.onDragOver(base.gameObject);
- }
- }
- private void OnDragOut()
- {
- if (this.onDragOut != null)
- {
- this.onDragOut(base.gameObject);
- }
- }
- private void OnDragEnd()
- {
- if (this.onDragEnd != null)
- {
- this.onDragEnd(base.gameObject);
- }
- }
- private void OnDrop(GameObject go)
- {
- if (this.onDrop != null)
- {
- this.onDrop(base.gameObject, go);
- }
- }
- private void OnKey(KeyCode key)
- {
- if (this.onKey != null)
- {
- this.onKey(base.gameObject, key);
- }
- }
- private void OnTooltip(bool show)
- {
- if (this.onTooltip != null)
- {
- this.onTooltip(base.gameObject, show);
- }
- }
- public static UIEventListener Get(GameObject go)
- {
- UIEventListener uieventListener = go.GetComponent<UIEventListener>();
- if (uieventListener == null)
- {
- uieventListener = go.AddComponent<UIEventListener>();
- }
- return uieventListener;
- }
- public object parameter;
- public UIEventListener.VoidDelegate onSubmit;
- public UIEventListener.VoidDelegate onClick;
- public UIEventListener.VoidDelegate onDoubleClick;
- public UIEventListener.BoolDelegate onHover;
- public UIEventListener.BoolDelegate onPress;
- public UIEventListener.BoolDelegate onSelect;
- public UIEventListener.FloatDelegate onScroll;
- public UIEventListener.VoidDelegate onDragStart;
- public UIEventListener.VectorDelegate onDrag;
- public UIEventListener.VoidDelegate onDragOver;
- public UIEventListener.VoidDelegate onDragOut;
- public UIEventListener.VoidDelegate onDragEnd;
- public UIEventListener.ObjectDelegate onDrop;
- public UIEventListener.KeyCodeDelegate onKey;
- public UIEventListener.BoolDelegate onTooltip;
- public delegate void VoidDelegate(GameObject go);
- public delegate void BoolDelegate(GameObject go, bool state);
- public delegate void FloatDelegate(GameObject go, float delta);
- public delegate void VectorDelegate(GameObject go, Vector2 delta);
- public delegate void ObjectDelegate(GameObject go, GameObject obj);
- public delegate void KeyCodeDelegate(GameObject go, KeyCode key);
- }
|