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

            scrollviewParentIDragHandler      = Scroll;
            scrollviewParentIBeginDragHandler = Scroll;
            scrollviewParentIEndDragHandler   = Scroll;
        }
Esempio n. 4
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);
        }
    public static int OnBeginDrag(IntPtr l)
    {
        int result;

        try
        {
            IBeginDragHandler beginDragHandler = (IBeginDragHandler)LuaObject.checkSelf(l);
            PointerEventData  eventData;
            LuaObject.checkType <PointerEventData>(l, 2, out eventData);
            beginDragHandler.OnBeginDrag(eventData);
            LuaObject.pushValue(l, true);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
Esempio n. 6
0
        public virtual void OnBeginDrag(PointerEventData data)
        {
            this.m_DragMove = false;
            this.m_Pos      = data.get_position();
            if (this.HasEvent((EventTriggerType)13))
            {
                this.Send((EventTriggerType)13, data.get_position());
            }
            if (!UnityEngine.Object.op_Inequality((UnityEngine.Object) this.syncEvent, (UnityEngine.Object)null))
            {
                return;
            }
            IBeginDragHandler component = (IBeginDragHandler)this.syncEvent.GetComponent <IBeginDragHandler>();

            if (component == null)
            {
                return;
            }
            component.OnBeginDrag(data);
        }
Esempio n. 7
0
 private static void Execute(IBeginDragHandler handler, BaseEventData eventData)
 {
     handler.OnBeginDrag(ValidateEventData <PointerEventData>(eventData));
 }
Esempio n. 8
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;
        }