void Awake()
 {
     dragHandler         = target as IDragHandler;
     endDragHandler      = target as IEndDragHandler;
     beginDragHandler    = target as IBeginDragHandler;
     pointerClickHandler = target as IPointerClickHandler;
 }
Exemplo n.º 2
0
 void Awake()
 {
     clicker = GetComponent(typeof(IPointerClickHandler)) as IPointerClickHandler;
     if (clicker == null) {
         Debug.LogError("Couldn't find IPointerClickHandler interface on any componenet on this object " + gameObject.name);
     }
 }
Exemplo n.º 3
0
        private void Update()
        {
            if (!Input.GetKeyDown(KeyCode.Tab))
            {
                return;
            }

            var selectable = _system.currentSelectedGameObject != null
                ? _system.currentSelectedGameObject.GetComponent <Selectable>()
                : null;

            if (selectable != null)
            {
                var next = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)
                    ? selectable.FindSelectableOnLeft() ?? selectable.FindSelectableOnUp()
                    : selectable.FindSelectableOnRight() ?? selectable.FindSelectableOnDown();

                if (next != null)
                {
                    IPointerClickHandler pointer = next.GetComponent <TMP_InputField>();
                    pointer?.OnPointerClick(new PointerEventData(_system));

                    _system.SetSelectedGameObject(next.gameObject);
                }
                else
                {
                    next = Selectable.allSelectablesArray[0];
                    _system.SetSelectedGameObject(next.gameObject);
                }
            }
        }
Exemplo n.º 4
0
    public void OnClickForLockedCursor()
    {
        if (PauseManager.isPaused == true)
        {
            return;
        }

        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit hit;
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            if (Physics.Raycast(ray, out hit, 100.0f))
            {
                bool hitThis = hit.transform.GetInstanceID() == transform.GetInstanceID();
                if (!hitThis)
                {
                    return;
                }

                IPointerClickHandler clickHandler     = hit.transform.gameObject.GetComponent <IPointerClickHandler>();
                PointerEventData     pointerEventData = new PointerEventData(EventSystem.current);
                if (clickHandler != null)
                {
                    clickHandler.OnPointerClick(pointerEventData);
                }
            }
        }
    }
Exemplo n.º 5
0
 private void PointerClick(IPointerClickHandler clicker, PointerEventData eventData)
 {
     if (clicker != null)
     {
         clicker.OnPointerClick(eventData);
     }
 }
		// 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;
		}
Exemplo n.º 7
0
 public EventTriggerListener RelayClick(IPointerClickHandler clickHandler)
 {
     if (!clickRelay.Contains(clickHandler))
     {
         clickRelay.Add(clickHandler);
     }
     return(this);
 }
Exemplo n.º 8
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));
        }
    }
Exemplo n.º 9
0
    void OnPointerClick(object sender, PointerEventArgs e)
    {
        IPointerClickHandler clickHandler = e.target.GetComponent <IPointerClickHandler>();

        clickHandler.OnPointerClick(new PointerEventData(EventSystem.current));

        // ExecuteEvents.Execute(e.target.gameObject
        // , new PointerEventData(EventSystem.current)
        // , ExecuteEvents.pointerClickHandler);
    }
Exemplo n.º 10
0
    void OnPointerClick(object sender, PointerEventArgs e)
    {
        IPointerClickHandler enter = e.target.GetComponent <IPointerClickHandler>();

        if (enter == null)
        {
            return;
        }

        enter.OnPointerClick(new PointerEventData(EventSystem.current));
    }
Exemplo n.º 11
0
    private void OnPointerClick(object sender, PointerEventArgs e)
    {
        IPointerClickHandler clickHandler = e.target.GetComponent <IPointerClickHandler>();

        if (clickHandler == null)
        {
            return;
        }

        ExecuteEvents.Execute(e.target.gameObject, new PointerEventData(EventSystem.current), ExecuteEvents.pointerClickHandler);
        //clickHandler.OnPointerClick(new PointerEventData(EventSystem.current));
    }
Exemplo n.º 12
0
    private void OnPointerClick(object sender, PointerEventArgs e)
    {
        IPointerClickHandler clickHandler = e.target.GetComponent <IPointerClickHandler>();

        if (clickHandler == null)
        {
            return;
        }
        Debug.Log("Clicked");

        clickHandler.OnPointerClick(new PointerEventData(EventSystem.current));
    }
        private void Execute(IPointerClickHandler handler, BaseEventData eventData)
        {
            var go = (handler as Component).gameObject;

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

            handler.OnPointerClick(ExecuteEvents.ValidateEventData <PointerEventData>(eventData));
        }
Exemplo n.º 14
0
    private void Update()
    {
        for (int i = 0; i < Input.touchCount; ++i)
        {
            if (Input.GetTouch(i).phase == TouchPhase.Began)
            {
                Ray ray = Camera.main.ScreenPointToRay(Input.GetTouch(i).position);

                if (Physics.Raycast(ray, out hit))
                {
                    clickHandler = hit.collider.gameObject.GetComponent <IPointerClickHandler>();
                    clickHandler.OnPointerClick(pointerEventData);
                }
            }
        }
    }
Exemplo n.º 15
0
        private void OnPointerClick(object sender, PointerEventArgs e)
        {
            IPointerClickHandler clickHandler = e.target.GetComponent <IPointerClickHandler>();

            if (clickHandler == null)
            {
                return;
            }


            PointerEventData myData = new PointerEventData(EventSystem.current)
            {
                worldPosition = e.position,
            };

            clickHandler.OnPointerClick(myData);
        }
Exemplo n.º 16
0
    public void ClickButtons()
    {
        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit hit;
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            if (Physics.Raycast(ray, out hit, 100.0f))
            {
                IPointerClickHandler clickHandler     = hit.transform.gameObject.GetComponent <IPointerClickHandler>();
                PointerEventData     pointerEventData = new PointerEventData(EventSystem.current);
                if (clickHandler != null)
                {
                    clickHandler.OnPointerClick(pointerEventData);
                }
            }
        }
    }
Exemplo n.º 17
0
    public static int OnPointerClick(IntPtr l)
    {
        int result;

        try
        {
            IPointerClickHandler pointerClickHandler = (IPointerClickHandler)LuaObject.checkSelf(l);
            PointerEventData     eventData;
            LuaObject.checkType <PointerEventData>(l, 2, out eventData);
            pointerClickHandler.OnPointerClick(eventData);
            LuaObject.pushValue(l, true);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
Exemplo n.º 18
0
        RectTransform GetFirstValidUI()
        {
            IPointerClickHandler pointer = null;

            for (int i = 0, l = _raycasts.Count; i < l; i++)
            {
                pointer = _raycasts[i].gameObject.GetComponent(typeof(IPointerClickHandler)) as IPointerClickHandler;
                if (pointer != null)
                {
                    return(_raycasts[i].gameObject.GetComponent(typeof(RectTransform)) as RectTransform);
                }
                pointer = _raycasts[i].gameObject.GetComponentInParent(typeof(IPointerClickHandler)) as IPointerClickHandler;
                if (pointer != null)
                {
                    return(_raycasts[i].gameObject.transform.parent.GetComponent(typeof(RectTransform)) as RectTransform);
                }
            }
            return(null);
        }
Exemplo n.º 19
0
    private void OnPointerClick(object sender, PointerEventArgs e)
    {
        IPointerClickHandler clickHandler = e.target.GetComponent <IPointerClickHandler>();

        if (clickHandler == null)
        {
            return;
        }

        var args  = new PointerEventData(EventSystem.current);
        var laser = sender as SteamVR_LaserPointer;

        if (args.selectedObject == null)
        {
            args.selectedObject = laser.gameObject;
        }
        Debug.Log(args.selectedObject.name);
        clickHandler.OnPointerClick(args);
    }
Exemplo n.º 20
0
    private void UIFire()
    {
        // Debug.Log("Fire");
        RaycastHit hit;

        if (Physics.Raycast(transform.position, transform.forward, out hit, 300))
        {
            IPointerClickHandler clickHandler = hit.collider.gameObject.GetComponent <IPointerClickHandler>();

            if (clickHandler != null)
            {
                Debug.Log("hit " + hit.collider.gameObject.name);
                PointerEventData pointerEventData = new PointerEventData(EventSystem.current);
                clickHandler.OnPointerClick(pointerEventData);
            }
            else
            {
                Debug.Log("hit not UI");
            }
        }
    }
Exemplo n.º 21
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);
    }
Exemplo n.º 22
0
    public void OnMouseDown()
    {
        if (!enabled)
        {
            return;
        }

        PointerEventData ped = new PointerEventData(es);

        ped.position = Input.mousePosition;
        List <RaycastResult> results = new List <RaycastResult>();

        es.RaycastAll(ped, results);

        foreach (RaycastResult result in results)
        {
            IPointerClickHandler pch = result.gameObject.GetComponent <IPointerClickHandler>();

            if (pch != null)
            {
                pch.OnPointerClick(ped);
            }
        }
    }
Exemplo n.º 23
0
 public UiTestDoubleClick(GameObject self)
 {
     _self             = self;
     _cellPointerClick = _self.GetComponent <IPointerClickHandler>();
     _pointerEventData = new PointerEventData(null);
 }
Exemplo n.º 24
0
 private static void Execute(IPointerClickHandler handler, BaseEventData eventData)
 {
     handler.OnPointerClick(ValidateEventData <PointerEventData>(eventData));
 }
Exemplo n.º 25
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();
    }
Exemplo n.º 26
0
 void Awake()
 {
     selectable   = GetComponent <Selectable>();
     clickHandler = GetComponent <Button>();
 }
Exemplo n.º 27
0
        private IPointerClickHandler UF_GetPointerClickHandler(GameObject gobj)
        {
            IPointerClickHandler ret = gobj.GetComponent <IPointerClickHandler>();

            return(ret);
        }
Exemplo n.º 28
0
 public static void ExecutePointerClick(IPointerClickHandler handler,
                                        BaseEventData data)
 {
     handler.OnPointerClick(ExecuteEvents
                            .ValidateEventData <PointerEventData>(data));
 }
Exemplo n.º 29
0
    private void Update()
    {
        //Move Hexagons
        bool panPressed = Input.GetMouseButton(2);

        if (panPressed && manager.action)
        {
            float xMov  = Input.GetAxis("Mouse X") * Time.deltaTime * sensitivity * 100f;
            float yMove = Input.GetAxis("Mouse Y") * Time.deltaTime * sensitivity * 100f;
            GameObject.Find(currentBranch).transform.position += new Vector3(xMov, yMove);
        }


        //Select Hexagon
        if (Input.GetMouseButtonDown(0) && manager.action)
        {
            //Code from https://gamedev.stackexchange.com/questions/93592/graphics-raycaster-of-unity-how-does-it-work

            //Code to be place in a MonoBehaviour with a GraphicRaycaster component
            GraphicRaycaster gr = GetComponent <GraphicRaycaster>();
            //Create the PointerEventData with null for the EventSystem
            PointerEventData ped = new PointerEventData(null);
            //Set required parameters, in this case, mouse position
            ped.position = Input.mousePosition;
            //Create list to receive all results
            List <RaycastResult> results = new List <RaycastResult>();
            //Raycast it
            gr.Raycast(ped, results);

            if (results[0].gameObject.GetComponent <Button>())
            {
                //Code from https://stackoverflow.com/questions/49321922/unity-raycast-ui-button-and-call-its-on-click-event
                IPointerClickHandler clickHandler     = results[0].gameObject.GetComponent <IPointerClickHandler>();
                PointerEventData     pointerEventData = new PointerEventData(EventSystem.current);
                clickHandler.OnPointerClick(pointerEventData);
            }
            else if (results[0].gameObject.layer == 8)
            {
                currentNode = results[0].gameObject.name;
                UpdateSelected(currentNode);
            }
        }

        //Disable enforce button when enforcing a law
        if (country.enforcingLaw)
        {
            enforceButton.interactable = false;
            //Progress bar
            progressBar.SetValues(country.lawEnforcementProgress);
        }
        else
        {
            progressBar.SetValues(0f);

            infectionRateText.text = string.Format("Infektionsrate:\n{0}%", country.disease.r0 * 100);
            severityText.text      = string.Format("Schwere:\n{0}%", country.disease.c * 100);
            deathRateText.text     = string.Format("Todesrate:\n{0}%", country.disease.f * 100);
            budgetText.text        = string.Format("{0}€", country.currentBudget);
            satisfactionText.text  = string.Format("Befriedigung:\n{0}", country.satisfaction);
        }
    }
Exemplo n.º 30
0
        // Token: 0x0600297A RID: 10618 RVA: 0x004598A0 File Offset: 0x00457AA0
        public virtual void OnEndDrag(PointerEventData eventData)
        {
            if (eventData.button != PointerEventData.InputButton.Left)
            {
                return;
            }
            float num  = Vector2.Distance(this.startPos, eventData.position);
            float num2 = Screen.dpi / 2.54f;

            if (num < num2 * 0.15f)
            {
                uButtonScale uButtonScale = eventData.pointerPressRaycast.gameObject.GetComponent(typeof(uButtonScale)) as uButtonScale;
                if (uButtonScale != null)
                {
                    uButtonScale.OnPointerClick(eventData);
                }
                else
                {
                    IPointerClickHandler pointerClickHandler = eventData.pointerPressRaycast.gameObject.GetComponent(typeof(IPointerClickHandler)) as IPointerClickHandler;
                    if (pointerClickHandler != null)
                    {
                        pointerClickHandler.OnPointerClick(eventData);
                    }
                    else
                    {
                        byte      b         = 3;
                        Transform transform = eventData.pointerPressRaycast.gameObject.transform;
                        while (b > 0 && transform.parent)
                        {
                            ScrollPanelItem component = transform.parent.GetComponent <ScrollPanelItem>();
                            if (component)
                            {
                                pointerClickHandler = (transform.parent.GetComponent(typeof(IPointerClickHandler)) as IPointerClickHandler);
                                if (pointerClickHandler != null)
                                {
                                    pointerClickHandler.OnPointerClick(eventData);
                                }
                                break;
                            }
                            b        -= 1;
                            transform = transform.parent;
                        }
                    }
                }
                this.startPos = Vector2.zero;
            }
            if (this.m_bInitViewState && (this.ViewState == ListViewState.LVS_PULL_REFRESH || this.ViewState == ListViewState.LVS_PULL_REFRESH_UP))
            {
                this.SwitchViewState(ListViewState.LVS_NORMAL);
            }
            if (this.bPageMove)
            {
                float num3 = Time.realtimeSinceStartup - this._time2;
                float num4 = eventData.position.x - this._pos2.x;
                float num5 = num4 / num3;
                if (GUIManager.Instance.IsArabic)
                {
                    if (this.NowPageIndex > 0 && (num5 < -500f || (double)(this.m_Content.anchoredPosition.x - this.m_ContentStartPosition.x) >= (double)this.PageWidth * 0.5))
                    {
                        this.setCurrentIndex(this.NowPageIndex - 1, false);
                    }
                    else if (this.NowPageIndex < this.PageQuantity - 1 && (num5 > 500f || (double)(-(double)(this.m_Content.anchoredPosition.x - this.m_ContentStartPosition.x)) >= (double)this.PageWidth * 0.5))
                    {
                        this.setCurrentIndex(this.NowPageIndex + 1, false);
                    }
                    else
                    {
                        this.setCurrentIndex(this.NowPageIndex, false);
                    }
                }
                else if (this.NowPageIndex > 0 && (num5 > 500f || (double)(this.m_Content.anchoredPosition.x - this.m_ContentStartPosition.x) >= (double)this.PageWidth * 0.5))
                {
                    this.setCurrentIndex(this.NowPageIndex - 1, false);
                }
                else if (this.NowPageIndex < this.PageQuantity - 1 && (num5 < -500f || (double)(-(double)(this.m_Content.anchoredPosition.x - this.m_ContentStartPosition.x)) >= (double)this.PageWidth * 0.5))
                {
                    this.setCurrentIndex(this.NowPageIndex + 1, false);
                }
                else
                {
                    this.setCurrentIndex(this.NowPageIndex, false);
                }
            }
            this.m_Dragging = false;
        }
Exemplo n.º 31
0
 public UiTestPointerButton(GameObject self)
 {
     _currentClickEventTime = UnityEngine.Time.time;
     _self             = self;
     _cellPointerClick = _self.GetComponent <IPointerClickHandler>();
 }