BaseView.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. 
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.EventSystems;
  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<SCButton>()) {
  19. gameObject.AddComponent<SCButton>();
  20. }
  21. EventManagerPatch.RemoveAllTriggerListener(gameObject);
  22. EventManagerPatch.AddTriggerListener(gameObject, EventTriggerType.PointerEnter, OnEnter);
  23. EventManagerPatch.AddTriggerListener(gameObject, EventTriggerType.PointerDown, OnDown);
  24. EventManagerPatch.AddTriggerListener(gameObject, EventTriggerType.PointerUp, OnUp);
  25. EventManagerPatch.AddTriggerListener(gameObject, EventTriggerType.PointerExit, OnExit);
  26. EventManagerPatch.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. }