Skip to content
This repository was archived by the owner on Feb 16, 2024. It is now read-only.
This repository was 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

Description

@doctorpangloss

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();
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions