ScrollRectInput.cs 840 B

12345678910111213141516171819202122232425262728293031
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEngine.UI;
  4. public class ScrollRectInput : ScrollRect , UILifeCycleInterface
  5. {
  6. public string m_UIEventKey;
  7. InputEventRegisterInfo<InputUIOnScrollEvent> m_register;
  8. public virtual void Init(string UIEventKey,int id)
  9. {
  10. m_UIEventKey = UIEventKey;
  11. m_register = InputUIEventProxy.GetOnScrollListener(m_UIEventKey, name, OnSetContentAnchoredPosition);
  12. }
  13. public virtual void Dispose()
  14. {
  15. m_register.RemoveListener();
  16. }
  17. protected override void SetContentAnchoredPosition(Vector2 position)
  18. {
  19. InputUIEventProxy.DispatchScrollEvent(m_UIEventKey, name,"", position);
  20. }
  21. protected virtual void OnSetContentAnchoredPosition(InputUIOnScrollEvent e)
  22. {
  23. base.SetContentAnchoredPosition(e.m_pos);
  24. }
  25. }