Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

OnPointerBeginDragHandler() should automatically add ObservableDragTrigger automatically otherwise events will not work #473

Open
doctorpangloss opened this issue Aug 25, 2020 · 1 comment · May be fixed by #541

Comments

@doctorpangloss
Copy link

From EventSystem docs:

 /// <summary>
    /// Interface to implement if you wish to receive OnBeginDrag callbacks.
    /// Note: You need to implement IDragHandler in addition to IBeginDragHandler.
    /// </summary>
    /// <remarks>
    /// Criteria for this event is implementation dependent. For example see StandAloneInputModule.
    /// </remarks>
    public interface IBeginDragHandler : IEventSystemHandler
    {
        /// <summary>
        /// Called by a BaseInputModule before a drag is started.
        /// </summary>
        void OnBeginDrag(PointerEventData eventData);
    }

You need to implement IDragHandler in addition to IBeginDragHandler.

This means OnBeginDragAsObservable should also just add the ObservableDragTrigger.

        public static IObservable<PointerEventData> OnBeginDragAsObservable(this Component component)
        {
            if (component == null || component.gameObject == null) return Observable.Empty<PointerEventData>();
            // Requires drag handler
            GetOrAddComponent<ObservableDragTrigger>(component.gameObject);
            return GetOrAddComponent<ObservableBeginDragTrigger>(component.gameObject).OnBeginDragAsObservable();
        }
@doctorpangloss
Copy link
Author

this is still burning people every day

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant