// Token: 0x060091D8 RID: 37336 RVA: 0x002A308C File Offset: 0x002A128C
		private bool Click(GameObject o)
		{
			if (o == null)
			{
				return false;
			}
			global::Debug.Log("[AndroidBackEventListener] Click GameObject:" + o.name);
			List<Component> list = new List<Component>();
			o.GetComponents(typeof(MonoBehaviour), list);
			bool result = false;
			foreach (Component component in list)
			{
				IPointerDownHandler pointerDownHandler = component as IPointerDownHandler;
				if (pointerDownHandler != null)
				{
					pointerDownHandler.OnPointerDown(new PointerEventData(EventSystem.current));
					result = true;
				}
				IPointerUpHandler pointerUpHandler = component as IPointerUpHandler;
				if (pointerUpHandler != null)
				{
					pointerUpHandler.OnPointerUp(new PointerEventData(EventSystem.current));
					result = true;
				}
				IPointerClickHandler pointerClickHandler = component as IPointerClickHandler;
				if (pointerClickHandler != null)
				{
					pointerClickHandler.OnPointerClick(new PointerEventData(EventSystem.current));
					result = true;
				}
			}
			return result;
		}
Ejemplo n.º 2
0
    private void SeekChildComponent(Transform _transform)
    {
        if (_transform == null)
        {
            return;
        }
        Component            component = null;
        IPointerClickHandler click     = null;
        IPointerDownHandler  down      = null;
        IPointerUpHandler    up        = null;
        ISubmitHandler       submit    = null;
        Transform            transform = null;

        for (int i = 0; i < _transform.childCount; i++)
        {
            transform = _transform.GetChild(i);
            click     = transform.GetComponent <IPointerClickHandler>();
            down      = transform.GetComponent <IPointerDownHandler>();
            up        = transform.GetComponent <IPointerUpHandler>();
            submit    = transform.GetComponent <ISubmitHandler>();

            if (click != null)
            {
                component = click as Component;
                hashClick[click.GetHashCode()]      = click;
                clickTestTimes[click.GetHashCode()] = 0;
                hashComponent[click.GetHashCode()]  = component;
            }

            if (down != null)
            {
                component = down as Component;
                hashDown[down.GetHashCode()]      = down;
                downTestTimes[down.GetHashCode()] = 0;
                hashComponent[down.GetHashCode()] = component;
            }

            if (up != null)
            {
                component = up as Component;
                hashUp[up.GetHashCode()]        = up;
                upTestTimes[up.GetHashCode()]   = 0;
                hashComponent[up.GetHashCode()] = component;
            }

            if (submit != null)
            {
                component = submit as Component;
                hashSubmit[submit.GetHashCode()]      = submit;
                submitTestTimes[submit.GetHashCode()] = 0;
                hashComponent[submit.GetHashCode()]   = component;
            }

            SeekChildComponent(_transform.GetChild(i));
        }
    }
        private void Execute(IPointerUpHandler handler, BaseEventData eventData)
        {
            var go = (handler as Component).gameObject;

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

            handler.OnPointerUp(ExecuteEvents.ValidateEventData <PointerEventData>(eventData));
        }
    public static int OnPointerUp(IntPtr l)
    {
        int result;

        try
        {
            IPointerUpHandler pointerUpHandler = (IPointerUpHandler)LuaObject.checkSelf(l);
            PointerEventData  eventData;
            LuaObject.checkType <PointerEventData>(l, 2, out eventData);
            pointerUpHandler.OnPointerUp(eventData);
            LuaObject.pushValue(l, true);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
Ejemplo n.º 5
0
 private static void Execute(IPointerUpHandler handler, BaseEventData eventData)
 {
     handler.OnPointerUp(ValidateEventData <PointerEventData>(eventData));
 }
Ejemplo n.º 6
0
 public static void ExecutePointerUp(IPointerUpHandler handler,
                                     BaseEventData data)
 {
     handler.OnPointerUp(ExecuteEvents
                         .ValidateEventData <PointerEventData>(data));
 }
Ejemplo n.º 7
0
    public void OnGUI()
    {
        if (testTool == null)
        {
            return;
        }
        GUILayout.Space(40);
        if (testTool.auto)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Space(400);
            EditorGUILayout.LabelField(string.Format("累计时间  {0} 秒", (int)testTool.autoCumulativeTime), GUILayout.ExpandWidth(true));
            GUILayout.Space(400);
            GUILayout.EndHorizontal();
        }
        GUILayout.Space(20);
        GUILayout.BeginHorizontal();
        GUILayout.Space(50);
        testTool.interVal = EditorGUILayout.FloatField("测试间隔", testTool.interVal, GUILayout.ExpandWidth(true));
        GUILayout.Space(50);
        testTool.TouchCount = EditorGUILayout.IntField("多点模拟", testTool.TouchCount, GUILayout.ExpandWidth(true));
        GUILayout.Space(50);
        if (!testTool.auto)
        {
            if (GUILayout.Button("开始", GUILayout.Width(50)))
            {
                testTool.StartAutoTest();
            }
        }
        else
        {
            if (GUILayout.Button("结束", GUILayout.Width(50)))
            {
                testTool.StopAutoTest();
            }
        }
        GUILayout.Space(50);
        GUILayout.EndHorizontal();
        GUILayout.Space(40);

        foreach (int key in testTool.hashComponent.Keys)
        {
            Component component = testTool.hashComponent[key];
            if (component == null)
            {
                continue;
            }
            GUILayout.Space(10);
            GUILayout.BeginHorizontal();

            GUILayout.Space(50);

            GUILayout.Label(component.gameObject.name, GUILayout.Width(150));
            IPointerClickHandler click  = null;
            IPointerDownHandler  down   = null;
            IPointerUpHandler    up     = null;
            ISubmitHandler       submit = null;

            GUILayout.Space(10);
            if (testTool.hashClick.TryGetValue(key, out click))
            {
                if (GUILayout.Button("Click"))
                {
                    click.OnPointerClick(new PointerEventData(EventSystem.current));
                    testTool.clickTestTimes[key]++;
                }

                EditorGUILayout.LabelField(testTool.clickTestTimes[key].ToString(), GUILayout.Width(30));
            }

            GUILayout.Space(10);
            if (testTool.hashDown.TryGetValue(key, out down))
            {
                if (GUILayout.Button("Down"))
                {
                    down.OnPointerDown(new PointerEventData(EventSystem.current));
                    testTool.downTestTimes[key]++;
                }

                EditorGUILayout.LabelField(testTool.downTestTimes[key].ToString(), GUILayout.Width(30));
            }

            GUILayout.Space(10);
            if (testTool.hashUp.TryGetValue(key, out up))
            {
                if (GUILayout.Button("Up"))
                {
                    up.OnPointerUp(new PointerEventData(EventSystem.current));
                    testTool.upTestTimes[key]++;
                }

                EditorGUILayout.LabelField(testTool.upTestTimes[key].ToString(), GUILayout.Width(30));
            }

            GUILayout.Space(10);
            if (testTool.hashSubmit.TryGetValue(key, out submit))
            {
                if (GUILayout.Button("Submit"))
                {
                    submit.OnSubmit(new PointerEventData(EventSystem.current));
                    testTool.submitTestTimes[key]++;
                }

                EditorGUILayout.LabelField(testTool.submitTestTimes[key].ToString(), GUILayout.Width(30));
            }

            GUILayout.EndHorizontal();
        }

        Repaint();
    }
Ejemplo n.º 8
0
 public UiTestUpDownButton(GameObject self)
 {
     _self        = self;
     _pointerDown = _self.GetComponent <IPointerDownHandler>();
     _pointerUp   = _self.GetComponent <IPointerUpHandler>();
 }
Ejemplo n.º 9
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>();
        }
    }
Ejemplo n.º 10
0
        /// <summary>
        /// 渲染当前添加的所有元素,在OnGUI进行调用,默认自动进行调用
        /// </summary>
        public void OnGUI()
        {
            Event evt = Event.current;


            if (evt.type == EventType.KeyDown && evt.control && evt.keyCode == KeyCode.R)
            {
                AssetDatabase.Refresh();
                evt.Use();
            }

            //先进行渲染
            if (evt.type == EventType.Repaint)
            {
                foreach (var VARIABLE in _rootElements)
                {
                    VARIABLE.Draw();
                }
            }

            //实现局部事件
            {
                Vector2 mousePos = evt.mousePosition;

                //Drag
                if (_pointerDragIndex != -1 && mousePos != _lastDragMousePosition)
                {
                    IPointerDragHandler drag = _uiElements[_pointerDragIndex] as IPointerDragHandler;
                    if (drag != null)
                    {
                        drag.OnDrag(mousePos - _lastDragMousePosition, mousePos);
                        _lastDragMousePosition = mousePos;
                        _refreshWindow         = true;
                    }
                }


                //PointerExit
                if (_pointerEnterIndex != -1)
                {
                    if (_uiElements.Count <= _pointerEnterIndex)
                    {
                        _pointerEnterIndex = -1;
                    }
                    else
                    {
                        IOverlapPoint ip = _uiElements[_pointerEnterIndex] as IOverlapPoint;
                        if (ip != null && !ip.OverlapPoint(mousePos, evt))
                        {
                            IPointerExitHandler ie = ip as IPointerExitHandler;
                            ie?.OnPointerExit();
                            _pointerEnterIndex = -1;
                        }
                    }
                }

                //PointerClickExit
                if (_pointerClickEnterIndex != -1)
                {
                    if (_uiElements.Count <= _pointerClickEnterIndex)
                    {
                        _pointerClickEnterIndex = -1;
                    }
                    else
                    {
                        IOverlapPoint ip = _uiElements[_pointerClickEnterIndex] as IOverlapPoint;
                        if (ip != null && !ip.OverlapPoint(mousePos, evt))
                        {
                            _pointerClickEnterIndex = -1;
                        }
                    }
                }

                //PointerEnter
                for (int i = _uiElements.Count - 1; i >= 0; i--)
                {
                    IPointerEnterHandler id = _uiElements[i] as IPointerEnterHandler;
                    if (id != null && id.OverlapPoint(mousePos, evt))
                    {
                        if (_pointerEnterIndex == -1 || _pointerEnterIndex < i)
                        {
                            if (_pointerEnterIndex != -1)
                            {
                                IPointerExitHandler ie = _uiElements[_pointerEnterIndex] as IPointerExitHandler;
                                ie?.OnPointerExit();
                            }

                            _pointerEnterIndex = i;
                            id.OnPointerEnter();
                            break;
                        }
                    }
                }

                //PointerClickEnter
                for (int i = _uiElements.Count - 1; i >= 0; i--)
                {
                    IPointerClickHandler id = _uiElements[i] as IPointerClickHandler;
                    if (id != null && id.OverlapPoint(mousePos, evt))
                    {
                        if (_pointerClickEnterIndex == -1 || _pointerClickEnterIndex < i)
                        {
                            _pointerClickEnterIndex = i;
                            break;
                        }
                    }
                }
            }

            //处理鼠标按下
            if (evt.type == EventType.MouseDown)
            {
                Vector2 mousePos = evt.mousePosition;

                bool hasFocus = false;
                //PointerDown
                for (int i = _uiElements.Count - 1; i >= 0; i--)
                {
                    UIElement     ui = _uiElements[i];
                    IOverlapPoint ip = ui as IOverlapPoint;

                    if (ip.OverlapPoint(mousePos, evt))
                    {
                        hasFocus = true;
                        IFocus focus = ui as IFocus;

                        IPointerDownHandler down = ui as IPointerDownHandler;

                        IPointerDragHandler drag = ui as IPointerDragHandler;

                        //Focus
                        if (focus != null)
                        {
                            //向上查找所有父亲
                            UIElement parent = ui;
                            while (parent != null)
                            {
                                focus = parent as IFocus;
                                if (focus != null)
                                {
                                    _focusElementsCur.Add(focus);
                                }

                                parent = parent.Parent;
                            }

                            //取消之前的
                            for (int i2 = _focusElements.Count - 1; i2 >= 0; i2--)
                            {
                                if (!_focusElementsCur.Contains(_focusElements[i2]))
                                {
                                    _focusElements[i2].Focus = false;
                                }
                            }


                            //聚焦现在的,从父亲到孩子
                            for (int i2 = _focusElementsCur.Count - 1; i2 >= 0; i2--)
                            {
                                _focusElementsCur[i2].Focus = true;
                            }

                            //交换之前与现在的列表,并清除现在
                            List <IFocus> temp = _focusElements;
                            _focusElements    = _focusElementsCur;
                            _focusElementsCur = temp;
                            _focusElementsCur.Clear();

                            if (down == null && drag == null)
                            {
                                break;
                            }
                        }

                        if (drag != null && _pointerDragIndex == -1 && evt.button == 0)
                        {
                            _pointerDragIndex = i;
                            drag.OnStartDrag(mousePos);

                            _lastDragMousePosition = mousePos;

                            if (down == null)
                            {
                                break;
                            }
                        }

                        if (down != null)
                        {
                            //PointerDown
                            down.OnPointerDown(mousePos, evt.shift, evt.control, evt.alt);
                            break;
                        }
                    }
                }


                //PointerClickDown
                for (int i = _uiElements.Count - 1; i >= 0; i--)
                {
                    IPointerClickHandler id = _uiElements[i] as IPointerClickHandler;
                    if (id != null && id.OverlapPoint(mousePos, evt) && _pointerClickPressIndex == -1)
                    {
                        _pointerClickPressButton = evt.button;
                        _pointerClickPressIndex  = i;
                        break;
                    }
                }

                //处理空白区域点击取消Focus
                if (!hasFocus)
                {
                    //取消焦点
                    for (int i2 = _focusElements.Count - 1; i2 >= 0; i2--)
                    {
                        _focusElements[i2].Focus = false;
                    }

                    _focusElements.Clear();
                }

                _refreshWindow = true;
            }

            //处理鼠标抬起
            if (evt.type == EventType.MouseUp || evt.type == EventType.MouseLeaveWindow)
            {
                Vector2 mousePos = evt.mousePosition;

                if (evt.button == 0)
                {
                    if (_pointerDragIndex != -1)
                    {
                        if (_uiElements[_pointerDragIndex] is IPointerDragHandler drag)
                        {
                            drag.OnDragEnd(mousePos);
                        }

                        _pointerDragIndex = -1;
                    }
                }

                //PointerUp
                for (int i = _uiElements.Count - 1; i >= 0; i--)
                {
                    IPointerUpHandler id = _uiElements[i] as IPointerUpHandler;
                    if (id != null && id.OverlapPoint(mousePos, evt))
                    {
                        id.OnPointerUp(mousePos);
                        break;
                    }
                }

                //PointerClickUp
                if (_pointerClickPressIndex != -1)
                {
                    if (_pointerClickEnterIndex != -1)
                    {
                        IPointerClickHandler ic = _uiElements[_pointerClickPressIndex] as IPointerClickHandler;
                        if (_pointerClickPressButton == evt.button)
                        {
                            if (_pointerClickPressIndex == _pointerClickEnterIndex)
                            {
                                ic?.OnClick(mousePos);
                            }
                            else
                            {
                                ic?.OnCancelClick(mousePos);
                            }
                        }
                        else
                        {
                            ic?.OnCancelClick(mousePos);
                        }

                        _pointerClickEnterIndex = -1;
                        _pointerClickPressIndex = -1;
                    }
                    else
                    {
                        IPointerClickHandler ic = _uiElements[_pointerClickPressIndex] as IPointerClickHandler;
                        ic?.OnCancelClick(mousePos);
                        _pointerClickEnterIndex = -1;
                        _pointerClickPressIndex = -1;
                    }
                }

                _refreshWindow = true;
            }

            //处理鼠标滚轮滑动
            if (evt.type == EventType.ScrollWheel)
            {
                for (int i = _uiElements.Count - 1; i >= 0; i--)
                {
                    IScrollHandler ic = _uiElements[i] as IScrollHandler;
                    ic?.OnScroll(evt.delta.y);
                }
            }

            //处理键盘按下
            if (evt.type == EventType.KeyDown)
            {
                if (evt.character != 0)
                {
                    for (int i = _uiElements.Count - 1; i >= 0; i--)
                    {
                        ICharacterInputHandler ic = _uiElements[i] as ICharacterInputHandler;
                        ic?.OnCharacterInput(evt.character);
                    }
                }

                for (int i = _uiElements.Count - 1; i >= 0; i--)
                {
                    IKeyDownHandler ui = _uiElements[i] as IKeyDownHandler;
                    ui?.OnKeyDown(evt.keyCode, evt.shift, evt.control, evt.alt);
                }

                evt.Use();

                _refreshWindow = true;
            }

            if (evt.type == EventType.KeyUp)
            {
                for (int i = _uiElements.Count - 1; i >= 0; i--)
                {
                    IKeyUpHandler ui = _uiElements[i] as IKeyUpHandler;
                    ui?.OnKeyUp(evt.keyCode);
                }

                evt.Use();

                _refreshWindow = true;
            }


            //RefreshAllElement
            if (_hasChangedElement)
            {
                RefreshAllElementInline();
                _hasChangedElement = false;
                _refreshWindow     = true;
            }

            //鼠标移动重绘
            if (_lastMoveMousePosition != evt.mousePosition)
            {
                _refreshWindow         = true;
                _lastDragMousePosition = evt.mousePosition;
            }

            //自动重绘界面
            if (_refreshWindow)
            {
                _refreshWindow = false;
                CurEditorWindow.Repaint();
            }
        }
Ejemplo n.º 11
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>();
        }
    }