private GameObject FindHandler(GameObject go, bool horizontal)
        {
            IDragHandler handler = go.GetComponentInParent <IDragHandler>();

            if (handler == null)
            {
                return(null);
            }

            ScrollRect scrollView = handler as ScrollRect;

            if (scrollView != null)
            {
                if (!scrollView.horizontal && horizontal)
                {
                    return(FindHandler(scrollView.gameObject.transform.parent.gameObject, horizontal));
                }

                if (!scrollView.vertical && !horizontal)
                {
                    return(FindHandler(scrollView.gameObject.transform.parent.gameObject, horizontal));
                }
            }

            MonoBehaviour behavior = handler as MonoBehaviour;

            if (behavior == null)
            {
                return(go);
            }

            return(behavior.gameObject);
        }
Beispiel #2
0
        public virtual void OnDrag(PointerEventData data)
        {
            if (this.HasEvent((EventTriggerType)5))
            {
                this.Send((EventTriggerType)5, data.get_position());
            }
            if (!this.m_DragMove)
            {
                Vector2 vector2 = Vector2.op_Subtraction(data.get_position(), this.m_Pos);
                // ISSUE: explicit reference operation
                if ((double)((Vector2)@vector2).get_magnitude() > 10.0)
                {
                    this.m_DragMove = true;
                }
            }
            if (!UnityEngine.Object.op_Inequality((UnityEngine.Object) this.syncEvent, (UnityEngine.Object)null))
            {
                return;
            }
            IDragHandler component = (IDragHandler)this.syncEvent.GetComponent <IDragHandler>();

            if (component == null)
            {
                return;
            }
            component.OnDrag(data);
        }
 void OnDragForParent(PointerEventData eventData, IDragHandler parent)
 {
     if (null != parent)
     {
         parent.OnDrag(eventData);
     }
 }
 void Awake()
 {
     dragHandler         = target as IDragHandler;
     endDragHandler      = target as IEndDragHandler;
     beginDragHandler    = target as IBeginDragHandler;
     pointerClickHandler = target as IPointerClickHandler;
 }
Beispiel #5
0
 public WindowNodeCreater(IDragHandler dragHandler, IFocusHandler focusHandler, ISignalHandler signalHandler, IWindowEventHandler windowHandler, IWindowTracker windowTracker, IPInvokeHandler pinvokeHandler)
 {
     this.dragHandler    = dragHandler;
     this.focusHandler   = focusHandler;
     this.signalHandler  = signalHandler;
     this.windowHandler  = windowHandler;
     this.windowTracker  = windowTracker;
     this.pinvokeHandler = pinvokeHandler;
 }
Beispiel #6
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(IDragHandler handler, BaseEventData eventData)
        {
            var go = (handler as Component).gameObject;

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

            handler.OnDrag(ExecuteEvents.ValidateEventData <PointerEventData>(eventData));
        }
Beispiel #9
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);
        }
Beispiel #10
0
    public static int OnDrag(IntPtr l)
    {
        int result;

        try
        {
            IDragHandler     dragHandler = (IDragHandler)LuaObject.checkSelf(l);
            PointerEventData eventData;
            LuaObject.checkType <PointerEventData>(l, 2, out eventData);
            dragHandler.OnDrag(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;
                }
            }
        }
Beispiel #12
0
    void Select(Selectable s, Selectable exclude = null)
    {
        m_excluded = exclude;

        if (m_currentSelectable)
        {
            m_currentSelectable.OnPointerExit(m_pointerEvent);
        }

        m_currentSelectable = s;

        if (m_currentSelectable)
        {
            m_currentSelectable.OnPointerEnter(m_pointerEvent);
            m_clickHandler = m_currentSelectable.GetComponent <IPointerClickHandler>();
            m_dragHandler  = m_currentSelectable.GetComponent <IDragHandler>();
        }

        m_elapsedTime = 0;
        m_onLoad.Invoke(m_elapsedTime / m_loadingTime);
    }
Beispiel #13
0
 public void AddDragHandler(IDragHandler dragHandler)
 {
     dragHandlers.Add(dragHandler);
 }
Beispiel #14
0
 private static void Execute(IDragHandler handler, BaseEventData eventData)
 {
     handler.OnDrag(ValidateEventData <PointerEventData>(eventData));
 }
Beispiel #15
0
    void Start()
    {
        // If the application is not running then return.
        if (Application.isPlaying == false)
        {
            return;
        }

        // Update the size and positioning of the button.
        switch (positioning)
        {
        default:
        case Positioning.Disabled:
        {
            // Do nothing.
        }
        break;

        case Positioning.ScreenSpace:
        {
            UpdatePositioning();
        }
        break;

        case Positioning.RelativeToJoystick:
        {
            StartCoroutine(WaitForPositioning());
        }
        break;

        case Positioning.RelativeToButton:
        {
            StartCoroutine(WaitForPositioning());
        }
        break;
        }

        // If the user is wanting to show the highlight color of the button, update the highlight images.
        if (showHighlight == true && buttonHighlight != null)
        {
            buttonHighlight.color = highlightColor;
        }

        // If the user is using tension fade options...
        if (showTension == true)
        {
            // Configure the speed variables for the fade.
            tensionFadeInSpeed  = 1.0f / tensionFadeInDuration;
            tensionFadeOutSpeed = 1.0f / tensionFadeOutDuration;
        }

        // If the user has useFade enabled...
        if (useFade == true)
        {
            // Get the CanvasGroup component for Enable/Disable options.
            canvasGroup = GetComponent <CanvasGroup>();

            // If the canvasGroup is null, then add a CanvasGroup and get the reference.
            if (canvasGroup == null)
            {
                gameObject.AddComponent(typeof(CanvasGroup));
                canvasGroup = GetComponent <CanvasGroup>();
            }

            // Configure the fade speeds.
            fadeInSpeed  = 1.0f / fadeInDuration;
            fadeOutSpeed = 1.0f / fadeOutDuration;

            // And apply the default fade for the button.
            canvasGroup.alpha = fadeUntouched;
        }

        // If the parent canvas doesn't have a UltimateButtonUpdater component, then add one.
        if (!GetParentCanvas().GetComponent <UltimateButtonScreenSizeUpdater>())
        {
            GetParentCanvas().gameObject.AddComponent(typeof(UltimateButtonScreenSizeUpdater));
        }

        if (transmitInput == true && receiver != null)
        {
            downHandler = receiver.GetComponent <IPointerDownHandler>();
            dragHandler = receiver.GetComponent <IDragHandler>();
            upHandler   = receiver.GetComponent <IPointerUpHandler>();
        }
    }
Beispiel #16
0
    void Start()
    {
        // If the application is not running then return.
        if (Application.isPlaying == false)
        {
            return;
        }

        // Update the size and positioning of the button.
        UpdatePositioning();

        // If the user is wanting to show the highlight color of the button, update the highlight images.
        if (showHighlight == true && buttonHighlight != null)
        {
            buttonHighlight.color = highlightColor;
        }

        // If the user is using tension fade options...
        if (showTension == true)
        {
            // Configure the speed variables for the fade.
            tensionFadeInSpeed  = 1.0f / tensionFadeInDuration;
            tensionFadeOutSpeed = 1.0f / tensionFadeOutDuration;
        }

        // If the user is wanting to show animation, then reference the HashID of the animator parameter.
        if (useAnimation == true && buttonAnimator != null)
        {
            animatorState = Animator.StringToHash("Touch");
        }

        // If the user has useFade enabled...
        if (useFade == true)
        {
            // Get the CanvasGroup component for Enable/Disable options.
            canvasGroup = GetComponent <CanvasGroup>();

            // If the canvasGroup is null, then add a CanvasGroup and get the reference.
            if (canvasGroup == null)
            {
                gameObject.AddComponent(typeof(CanvasGroup));
                canvasGroup = GetComponent <CanvasGroup>();
            }

            // Configure the fade speeds.
            fadeInSpeed  = 1.0f / fadeInDuration;
            fadeOutSpeed = 1.0f / fadeOutDuration;

            // And apply the default fade for the button.
            canvasGroup.alpha = fadeUntouched;
        }

        // If the parent canvas doesn't have a UltimateButtonUpdater component, then add one.
        if (!GetParentCanvas().GetComponent <UltimateButtonUpdater>())
        {
            GetParentCanvas().gameObject.AddComponent(typeof(UltimateButtonUpdater));
        }

        if (transmitInput == true && receiver != null)
        {
            downHandler = receiver.GetComponent <IPointerDownHandler>();
            dragHandler = receiver.GetComponent <IDragHandler>();
            upHandler   = receiver.GetComponent <IPointerUpHandler>();
        }
    }
Beispiel #17
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;
        }
Beispiel #18
0
 public void RegisterDrag(IDragHandler handler) => _dragHandler = handler;
Beispiel #19
0
 public static void SetDragHandler(DependencyObject obj, IDragHandler value)
 {
     obj.SetValue(DragDropHelper.DragHandlerProperty, (object) value);
 }