Ejemplo n.º 1
0
 void OnEndDragForParent(PointerEventData eventData, IEndDragHandler parent)
 {
     if (null != parent)
     {
         parent.OnEndDrag(eventData);
     }
 }
 void Awake()
 {
     dragHandler         = target as IDragHandler;
     endDragHandler      = target as IEndDragHandler;
     beginDragHandler    = target as IBeginDragHandler;
     pointerClickHandler = target as IPointerClickHandler;
 }
Ejemplo n.º 3
0
        public void Setup()
        {
            if (Scroll == null)
            {
                Scroll = GetComponentInParent <ScrollRect>();
            }

            scrollviewParentIDragHandler      = Scroll;
            scrollviewParentIBeginDragHandler = Scroll;
            scrollviewParentIEndDragHandler   = Scroll;
        }
        private void EndDrag()
        {
            if (dragEndHandler != null)
            {
                var pointerData = new PointerEventData(EvSystem);
                pointerData.position = transform.position;

                dragEndHandler.OnEndDrag(pointerData);
            }
            dragEndHandler = null;
            dragHandler    = null;
        }
        private void Execute(IEndDragHandler handler, BaseEventData eventData)
        {
            var go = (handler as Component).gameObject;

            Debug.LogWarning("IEndDragHandler : " + go.name);
            OnEvent(handler, eventData);
            if (SkipSendTouch)
            {
                return;
            }

            handler.OnEndDrag(ExecuteEvents.ValidateEventData <PointerEventData>(eventData));
        }
Ejemplo n.º 6
0
        public bool FindAndStoreNestedParent()
        {
            initializePotentialDragHandler = null;
            beginDragHandler = null;
            dragHandler      = null;
            endDragHandler   = null;

            var tr = _Adapter.transform;

            // Find the first parent that implements all of the interfaces
            while ((tr = tr.parent) && initializePotentialDragHandler == null)
            {
                initializePotentialDragHandler = tr.GetComponent(typeof(IInitializePotentialDragHandler)) as IInitializePotentialDragHandler;
                if (initializePotentialDragHandler == null)
                {
                    continue;
                }

                beginDragHandler = initializePotentialDragHandler as IBeginDragHandler;
                if (beginDragHandler == null)
                {
                    initializePotentialDragHandler = null;
                    continue;
                }

                dragHandler = initializePotentialDragHandler as IDragHandler;
                if (dragHandler == null)
                {
                    initializePotentialDragHandler = null;
                    beginDragHandler = null;
                    continue;
                }

                endDragHandler = initializePotentialDragHandler as IEndDragHandler;
                if (endDragHandler == null)
                {
                    initializePotentialDragHandler = null;
                    beginDragHandler = null;
                    dragHandler      = null;
                    continue;
                }
            }

            _SearchedAtLeastOnce = true;

            return(initializePotentialDragHandler != null);
        }
Ejemplo n.º 7
0
        public virtual void OnEndDrag(PointerEventData data)
        {
            this.m_DragMove = false;
            if (this.HasEvent((EventTriggerType)14))
            {
                this.Send((EventTriggerType)14, data.get_position());
            }
            if (!UnityEngine.Object.op_Inequality((UnityEngine.Object) this.syncEvent, (UnityEngine.Object)null))
            {
                return;
            }
            IEndDragHandler component = (IEndDragHandler)this.syncEvent.GetComponent <IEndDragHandler>();

            if (component == null)
            {
                return;
            }
            component.OnEndDrag(data);
        }
Ejemplo n.º 8
0
    public static int OnEndDrag(IntPtr l)
    {
        int result;

        try
        {
            IEndDragHandler  endDragHandler = (IEndDragHandler)LuaObject.checkSelf(l);
            PointerEventData eventData;
            LuaObject.checkType <PointerEventData>(l, 2, out eventData);
            endDragHandler.OnEndDrag(eventData);
            LuaObject.pushValue(l, true);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
        private void GetDraggable()
        {
            var pointerData = new PointerEventData(EvSystem);

            pointerData.position = transform.position;

            EvSystem.RaycastAll(pointerData, raycastResults);
            foreach (var result in raycastResults)
            {
                dragHandler = result.gameObject.GetComponentInParent <IDragHandler>();
                if (dragHandler != null)
                {
                    dragEndHandler = result.gameObject.GetComponentInParent <IEndDragHandler>();
                    result.gameObject.GetComponentInParent <IBeginDragHandler>().OnBeginDrag(pointerData);
                    result.gameObject.GetComponentInParent <IInitializePotentialDragHandler>().OnInitializePotentialDrag(pointerData);
                    dragHandler.OnDrag(pointerData);
                    return;
                }
            }
        }
Ejemplo n.º 10
0
 private static void Execute(IEndDragHandler handler, BaseEventData eventData)
 {
     handler.OnEndDrag(ValidateEventData <PointerEventData>(eventData));
 }
Ejemplo n.º 11
0
        public void FindAndStoreNestedParent()
        {
            parentInitializePotentialDragHandler = null;
            parentBeginDragHandler = null;
            parentDragHandler      = null;
            parentEndDragHandler   = null;
            parentScrollHandler    = null;

            var tr = _Adapter.transform;

            // Find the first parent that implements all of the interfaces
            while ((tr = tr.parent) && parentInitializePotentialDragHandler == null)
            {
                parentInitializePotentialDragHandler = tr.GetComponent(typeof(IInitializePotentialDragHandler)) as IInitializePotentialDragHandler;
                if (parentInitializePotentialDragHandler == null)
                {
                    continue;
                }

                parentBeginDragHandler = parentInitializePotentialDragHandler as IBeginDragHandler;
                if (parentBeginDragHandler == null)
                {
                    parentInitializePotentialDragHandler = null;
                    continue;
                }

                parentDragHandler = parentInitializePotentialDragHandler as IDragHandler;
                if (parentDragHandler == null)
                {
                    parentInitializePotentialDragHandler = null;
                    parentBeginDragHandler = null;
                    continue;
                }

                parentEndDragHandler = parentInitializePotentialDragHandler as IEndDragHandler;
                if (parentEndDragHandler == null)
                {
                    parentInitializePotentialDragHandler = null;
                    parentBeginDragHandler = null;
                    parentDragHandler      = null;
                    continue;
                }
            }

            if (parentInitializePotentialDragHandler == null)
            {
                // Search for the scroll handler separately, if no drag handlers present
                tr = _Adapter.transform;
                while ((tr = tr.parent) && parentScrollHandler == null)
                {
                    parentScrollHandler = tr.GetComponent(typeof(IScrollHandler)) as IScrollHandler;
                }
            }
            else
            {
                // Only allow the scroll handler to be taken from the drag handler, if any, so all handlers will come from the same object
                parentScrollHandler = parentInitializePotentialDragHandler as IScrollHandler;
            }

            _SearchedAtLeastOnce = true;
        }