/// <summary> /// 指针移动 /// </summary> void MouseMove() { float h = Control.instance.IsHorizontal(); float v = Control.instance.IsVertical(); if (v != 0 || h != 0) { GuiMouse.POINT pt = GuiMouse.GetMousePos(); pt.X += (int)(h * 10); pt.Y -= (int)(v * 10); GuiMouse.SetMousePos(pt); } }
/// <summary> /// 选择按钮 /// </summary> void SelectBtn() { if (Control.instance.IsJudgment()) { //Debug.Log("触发了选择"); Selectable next = null; Selectable current = null; // 找出我们是否有一个有效的当前选择的游戏对象 if (eventSystem.currentSelectedGameObject != null) { // Unity似乎没有“取消选择”一个不活动的对象 if (eventSystem.currentSelectedGameObject.activeInHierarchy) { current = eventSystem.currentSelectedGameObject.GetComponent <Selectable>(); } } if (current != null) { // 当SHIFT与标签一起被按住时,向后移动而不是向前移动 if (Control.instance.IsLast()) { //Debug.Log("触发了向前选择"); next = current.FindSelectableOnLeft(); if (next == null) { next = current.FindSelectableOnUp(); } } else { //Debug.Log("触发了向后选择"); next = current.FindSelectableOnRight(); if (next == null) { next = current.FindSelectableOnDown(); if (next == null) { current = eventSystem.firstSelectedGameObject.GetComponent <Selectable>(); next = current; } } } } else { // 如果没有当前选择的游戏对象,选择第一个 if (Selectable.allSelectables.Count > 0) { next = Selectable.allSelectables[0]; getCom = false; } } if (next != null) { next.Select(); select = next; image.SetParent(next.transform, false); Vector2 winPos = uiCamera.WorldToScreenPoint(image.transform.position); var screenPos = calculationScreenPosition.CalculationScreenPos(winPos); GuiMouse.SetMousePos(screenPos); } } }