public void Use() { var pointerEventData = new PointerEventData(null); _pointerDown.OnPointerDown(pointerEventData); _pointerUp.OnPointerUp(pointerEventData); }
// 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; }
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)); }
void Update() { if (!auto) { return; } autoCumulativeTime += Time.deltaTime; if (timer < interVal) { timer += Time.deltaTime; return; } timer = 0f; for (int i = 0; i < TouchCount; i++) { if (keys == null || keys.Count == 0) { break; } int index = UnityEngine.Random.Range(0, keys.Count); int key = keys[index]; if (hashClick.TryGetValue(key, out clickHandler)) { clickHandler.OnPointerClick(new PointerEventData(EventSystem.current)); clickTestTimes[key]++; } if (hashDown.TryGetValue(key, out downHandler)) { downHandler.OnPointerDown(new PointerEventData(EventSystem.current)); downTestTimes[key]++; } if (hashUp.TryGetValue(key, out upHandler)) { upHandler.OnPointerUp(new PointerEventData(EventSystem.current)); upTestTimes[key]++; } if (hashSubmit.TryGetValue(key, out submitHandler)) { submitHandler.OnSubmit(new PointerEventData(EventSystem.current)); submitTestTimes[key]++; } } }
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); }
private static void Execute(IPointerUpHandler handler, BaseEventData eventData) { handler.OnPointerUp(ValidateEventData <PointerEventData>(eventData)); }
public static void ExecutePointerUp(IPointerUpHandler handler, BaseEventData data) { handler.OnPointerUp(ExecuteEvents .ValidateEventData <PointerEventData>(data)); }
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(); }
// This function is called when the user has let go of the input. public void OnPointerUp(PointerEventData touchInfo) { // If the pointer event that is calling this function is not the same as the one that initiated the button, then return. if (touchInfo.pointerId != _pointerId) { return; } // Set the buttons state to false. getButton = false; // Set the stored pointer ID to a null value. _pointerId = -10; // If the input is not currently hovering over the button, then return. if (isHovering == false) { return; } // If the button name has been assigned, then broadcast the button's state. if (buttonName != string.Empty) { StartCoroutine("GetButtonUpDelay"); } // If the up event is assigned, then call the event. if (onButtonUp != null) { onButtonUp.Invoke(); } // If the user is wanting to count the amount of taps by Touch and Release... if (tapCountOption == TapCountOption.TouchRelease) { // Then check the current tap time to see if the release is happening within time. if (currentTapTime > 0) { // Call the button events. if (buttonName != string.Empty) { StartCoroutine("GetTapCountDelay"); } if (tapCountEvent != null) { tapCountEvent.Invoke(); } } // Set the tap time to 0 to reset the timer. currentTapTime = 0; } // If the user is wanting to show animations, then set the animator. if (useAnimation == true && buttonAnimator != null) { buttonAnimator.SetBool(animatorState, false); } // Set isHovering to false since the touch input has been released. isHovering = false; // If the user wants to transmit the input and the OnPointerUp variable is assigned, then call the function. if (transmitInput == true && upHandler != null) { upHandler.OnPointerUp(touchInfo); } }
/// <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(); } }