BaseView.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.EventSystems;
  5. using UnityEngine.UI;
  6. public abstract class BaseView :BaseWindow {
  7. public object config;
  8. public bool isSelect;
  9. public int index;
  10. public override void Start() {
  11. base.Start();
  12. isSelect = false;
  13. AddEvent();
  14. }
  15. public override void Init() {
  16. }
  17. public void AddEvent() {
  18. if (!gameObject.GetComponent<Button>()) {
  19. gameObject.AddComponent<Button>();
  20. }
  21. OBEEventManager.RemoveAllTriggerListener(gameObject);
  22. OBEEventManager.AddTriggerListener(gameObject, EventTriggerType.PointerEnter, OnEnter);
  23. OBEEventManager.AddTriggerListener(gameObject, EventTriggerType.PointerDown, OnDown);
  24. OBEEventManager.AddTriggerListener(gameObject, EventTriggerType.PointerUp, OnUp);
  25. OBEEventManager.AddTriggerListener(gameObject, EventTriggerType.PointerExit, OnExit);
  26. OBEEventManager.AddTriggerListener(gameObject, EventTriggerType.PointerClick, OnClick);
  27. }
  28. public virtual void OnEnter(BaseEventData data) {
  29. }
  30. public virtual void OnDown(BaseEventData data) {
  31. }
  32. public virtual void OnUp(BaseEventData data) {
  33. }
  34. public virtual void OnExit(BaseEventData data) {
  35. }
  36. public virtual void OnClick(BaseEventData data) {
  37. }
  38. public virtual void Refresh() {
  39. }
  40. }