1
0

ObservableInitializePotentialDragTrigger.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // for uGUI(from 4.6)
  2. #if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
  3. using System; // require keep for Windows Universal App
  4. using UnityEngine;
  5. using UnityEngine.EventSystems;
  6. namespace UniRx.Triggers
  7. {
  8. [DisallowMultipleComponent]
  9. public class ObservableInitializePotentialDragTrigger : ObservableTriggerBase, IEventSystemHandler, IInitializePotentialDragHandler
  10. {
  11. Subject<PointerEventData> onInitializePotentialDrag;
  12. void IInitializePotentialDragHandler.OnInitializePotentialDrag(PointerEventData eventData)
  13. {
  14. if (onInitializePotentialDrag != null) onInitializePotentialDrag.OnNext(eventData);
  15. }
  16. public IObservable<PointerEventData> OnInitializePotentialDragAsObservable()
  17. {
  18. return onInitializePotentialDrag ?? (onInitializePotentialDrag = new Subject<PointerEventData>());
  19. }
  20. protected override void RaiseOnCompletedOnDestroy()
  21. {
  22. if (onInitializePotentialDrag != null)
  23. {
  24. onInitializePotentialDrag.OnCompleted();
  25. }
  26. }
  27. }
  28. }
  29. #endif