void Update() { if (m_MouseOrTouch != null) { if (!m_MouseOrTouch.pressStarted) { m_MouseOrTouch = null; m_JoystickBG.localPosition = Vector3.zero; m_JoystickToggle.localPosition = Vector3.zero; m_Offset = Vector3.zero; return; } else { //put whole joystick to current finger/cursor position. m_JoystickToggle.position = m_CurrentCamera.ScreenToWorldPoint(m_MouseOrTouch.pos); //restrict toggle's position within the BG. float Dis = Vector3.Distance(Vector3.zero, m_JoystickToggle.localPosition); if (Dis > MaxRadiusDistance) { m_JoystickToggle.localPosition = m_JoystickToggle.localPosition.normalized * MaxRadiusDistance; } m_Offset = new Vector3(m_JoystickToggle.localPosition.x, 0, m_JoystickToggle.localPosition.y); } } }
static public int set_pressStarted(IntPtr l) { try { UICamera.MouseOrTouch self = (UICamera.MouseOrTouch)checkSelf(l); System.Boolean v; checkType(l, 2, out v); self.pressStarted = v; pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int set_clickNotification(IntPtr l) { try { UICamera.MouseOrTouch self = (UICamera.MouseOrTouch)checkSelf(l); UICamera.ClickNotification v; checkEnum(l, 2, out v); self.clickNotification = v; pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int set_clickTime(IntPtr l) { try { UICamera.MouseOrTouch self = (UICamera.MouseOrTouch)checkSelf(l); System.Single v; checkType(l, 2, out v); self.clickTime = v; pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int set_key(IntPtr l) { try { UICamera.MouseOrTouch self = (UICamera.MouseOrTouch)checkSelf(l); UnityEngine.KeyCode v; checkEnum(l, 2, out v); self.key = v; pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int set_dragged(IntPtr l) { try { UICamera.MouseOrTouch self = (UICamera.MouseOrTouch)checkSelf(l); UnityEngine.GameObject v; checkType(l, 2, out v); self.dragged = v; pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int set_pressedCam(IntPtr l) { try { UICamera.MouseOrTouch self = (UICamera.MouseOrTouch)checkSelf(l); UnityEngine.Camera v; checkType(l, 2, out v); self.pressedCam = v; pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int set_totalDelta(IntPtr l) { try { UICamera.MouseOrTouch self = (UICamera.MouseOrTouch)checkSelf(l); UnityEngine.Vector2 v; checkType(l, 2, out v); self.totalDelta = v; pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
//UIManager.singleton.CurrentTouchID = -1 ==> 鼠标左击 //UIManager.singleton.CurrentTouchID = -2 ==> 鼠标右击 public void OnClick() { this.m_log.Debug("Onclick"); UICamera.MouseOrTouch currentTouch = UIManager.singleton.CurrentTouch; if (null == currentTouch) { this.m_log.Error("null == mouseOrTouch"); } else { bool isEventProcessed = UIManager.singleton.IsEventProcessed; if (Camera.main != null) { if (UIManager.singleton.CurrentTouchID == -2 && !isEventProcessed) { } if (UIManager.singleton.CurrentTouchID != -2 && !isEventProcessed) { isEventProcessed = Singleton <OpStateManager> .singleton.OnClick(); if (isEventProcessed) { UIManager.singleton.IsEventProcessed = true; } } if (!UIManager.singleton.IsAnyTouchInUI && UIManager.singleton.CurrentTouchID != -2 && !isEventProcessed) { Debug.Log("点击的地方ID飞机的飞机覅"); Ray ray = Camera.main.ScreenPointToRay(new Vector3(currentTouch.pos.x, currentTouch.pos.y, 0f)); RaycastHit hit; Debug.Log("射线是否碰撞到物体:" + Physics.Raycast(ray, out hit, float.PositiveInfinity, UnityEngine.LayerMask.NameToLayer("HexagonMap"))); Debug.Log(this.m_layerMask); Debug.Log("摄像是否碰到物体后来的:" + Physics.Raycast(ray, out hit, float.PositiveInfinity)); if (Physics.Raycast(ray, out hit, float.PositiveInfinity, this.m_layerMask)) { this.m_log.Debug("Raycast:hit=:" + hit.transform.name); int num = 1 << hit.transform.gameObject.layer; if ((num & this.m_layerMaskForMap) > 0) { hit.transform.gameObject.SendMessage("OnClick", hit.point, SendMessageOptions.DontRequireReceiver); } else { hit.transform.gameObject.SendMessage("OnClick"); } } } } } }
public virtual void StartDragging() { if (!this.interactable) { return; } if (!this.mDragging) { if (this.cloneOnDrag) { this.mPressed = false; GameObject gameObject = base.transform.parent.gameObject.AddChild(base.gameObject); gameObject.transform.localPosition = base.transform.localPosition; gameObject.transform.localRotation = base.transform.localRotation; gameObject.transform.localScale = base.transform.localScale; UIButtonColor component = gameObject.GetComponent <UIButtonColor>(); if (component != null) { component.defaultColor = base.GetComponent <UIButtonColor>().defaultColor; } if (this.mTouch != null && this.mTouch.pressed == base.gameObject) { this.mTouch.current = gameObject; this.mTouch.pressed = gameObject; this.mTouch.dragged = gameObject; this.mTouch.last = gameObject; } UIDragDropItem component2 = gameObject.GetComponent <UIDragDropItem>(); component2.mTouch = this.mTouch; component2.mPressed = true; component2.mDragging = true; component2.Start(); component2.OnClone(base.gameObject); component2.OnDragDropStart(); if (UICamera.currentTouch == null) { UICamera.currentTouch = this.mTouch; } this.mTouch = null; UICamera.Notify(base.gameObject, "OnPress", false); UICamera.Notify(base.gameObject, "OnHover", false); } else { this.mDragging = true; this.OnDragDropStart(); } } }
void OnClick() { UICamera.MouseOrTouch currentTouch = UICamera.currentTouch; // currentTouch. if (mWindow != null) { int frameCount = 0; foreach (var frame in mFrameSpr) { if (UICamera.selectedObject != frame.gameObject) { frameCount++; } } if (mWindow.IsShow && frameCount == mFrameSpr.Count) { if (mFrameSpr.Count != 0) { // Vector3 panelScreenPos = xc.ui.UIManager.GetInstance().UIMain.MainCam.WorldToScreenPoint(mFrameSpr.transform.position); int idx = 0; foreach (var frameSpr in mFrameSpr) { Vector2 vec = NGUIMath.ScreenToPixels(currentTouch.pos, frameSpr.transform); float minx = -frameSpr.width / 2; float miny = -frameSpr.height / 2; float maxx = +frameSpr.width / 2; float maxy = +frameSpr.height / 2; if (vec.x < minx || vec.x > maxx || vec.y < miny || vec.y > maxy) { var item = UICamera.selectedObject.GetComponent <xc.ui.UIItemSlot>(); if (item == null) { idx++; } else if (item.ItemInfo == null) { idx++; } } } if (idx == mFrameSpr.Count && onLost != null) { onLost(); } } } } }
protected virtual void OnClick() { if (clickToDrag && !mDragging && UICamera.currentTouchID == -1 && draggedItems.Count == 0) { mTouch = UICamera.currentTouch; var item = StartDragging(); if (clickToDrag && item != null) { UICamera.onMouseMove += item.OnDrag; UICamera.onPress += item.OnGlobalPress; UICamera.onClick += item.OnGlobalClick; } } }
private void OnRelease(GameObject go, bool isPress) { if (isPress == false) { UICamera.MouseOrTouch t = UICamera.currentTouch; if (t != null) { bool isChild = CheckIsChild(List.gameObject.transform, t.pressed.transform); if (isChild == false && t.pressed.transform != Btn.transform) { //List.gameObject.SetActive(false); ActivieList(false); } } } }
static int get_lastPos(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UICamera.MouseOrTouch obj = (UICamera.MouseOrTouch)o; UnityEngine.Vector2 ret = obj.lastPos; ToLua.Push(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index lastPos on a nil value" : e.Message)); } }
static int get_clickNotification(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UICamera.MouseOrTouch obj = (UICamera.MouseOrTouch)o; UICamera.ClickNotification ret = obj.clickNotification; ToLua.Push(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index clickNotification on a nil value" : e.Message)); } }
static int set_dragStarted(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UICamera.MouseOrTouch obj = (UICamera.MouseOrTouch)o; bool arg0 = LuaDLL.luaL_checkboolean(L, 2); obj.dragStarted = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index dragStarted on a nil value" : e.Message)); } }
static int get_isOverUI(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UICamera.MouseOrTouch obj = (UICamera.MouseOrTouch)o; bool ret = obj.isOverUI; LuaDLL.lua_pushboolean(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index isOverUI on a nil value" : e.Message)); } }
static int get_deltaTime(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UICamera.MouseOrTouch obj = (UICamera.MouseOrTouch)o; float ret = obj.deltaTime; LuaDLL.lua_pushnumber(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index deltaTime on a nil value" : e.Message)); } }
static int set_totalDelta(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UICamera.MouseOrTouch obj = (UICamera.MouseOrTouch)o; UnityEngine.Vector2 arg0 = ToLua.ToVector2(L, 2); obj.totalDelta = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index totalDelta on a nil value" : e.Message)); } }
static int set_dragged(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UICamera.MouseOrTouch obj = (UICamera.MouseOrTouch)o; UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.CheckUnityObject(L, 2, typeof(UnityEngine.GameObject)); obj.dragged = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index dragged on a nil value" : e.Message)); } }
static int set_clickTime(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UICamera.MouseOrTouch obj = (UICamera.MouseOrTouch)o; float arg0 = (float)LuaDLL.luaL_checknumber(L, 2); obj.clickTime = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index clickTime on a nil value" : e.Message)); } }
static int set_clickNotification(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UICamera.MouseOrTouch obj = (UICamera.MouseOrTouch)o; UICamera.ClickNotification arg0 = (UICamera.ClickNotification)ToLua.CheckObject(L, 2, typeof(UICamera.ClickNotification)); obj.clickNotification = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index clickNotification on a nil value" : e.Message)); } }
protected virtual void StartDragging() { if (!interactable || mDragging) { return; } if (cloneOnDrag) { mPressed = false; GameObject gameObject = NGUITools.AddChild(base.transform.parent.gameObject, base.gameObject); gameObject.transform.localPosition = base.transform.localPosition; gameObject.transform.localRotation = base.transform.localRotation; gameObject.transform.localScale = base.transform.localScale; UIButtonColor component = gameObject.GetComponent <UIButtonColor>(); if (component != null) { component.defaultColor = GetComponent <UIButtonColor>().defaultColor; } if (mTouch != null && mTouch.pressed == base.gameObject) { mTouch.current = gameObject; mTouch.pressed = gameObject; mTouch.dragged = gameObject; mTouch.last = gameObject; } UIDragDropItem component2 = gameObject.GetComponent <UIDragDropItem>(); component2.mTouch = mTouch; component2.mPressed = true; component2.mDragging = true; component2.Start(); component2.OnDragDropStart(); if (UICamera.currentTouch == null) { UICamera.currentTouch = mTouch; } mTouch = null; UICamera.Notify(base.gameObject, "OnPress", false); UICamera.Notify(base.gameObject, "OnHover", false); } else { mDragging = true; OnDragDropStart(); } }
void OnDrag(Vector2 delta) { if (!enabled || targetFSM == null) { return; } if (debug) { UnityEngine.Debug.Log("NGuiEventsToPlaymakerFsmEvents OnDrag(" + delta + ") to " + targetFSM.gameObject.name + "/" + targetFSM.FsmName); } Fsm.EventData.Vector3Data = new Vector3(delta.x, delta.y); currentTouch = UICamera.currentTouch; FireNGUIPlayMakerEvent(NGuiPlayMakerDelegates.OnDragEvent); }
protected virtual void OnPress(bool isPressed) { if (!this.interactable) { return; } if (isPressed) { this.mTouch = UICamera.currentTouch; this.mDragStartTime = RealTime.time + this.pressAndHoldDelay; this.mPressed = true; } else { this.mPressed = false; this.mTouch = null; } }
void OnTooltip(bool show) { if (!enabled || targetFSM == null) { return; } if (debug) { UnityEngine.Debug.Log("NGuiEventsToPlaymakerFsmEvents OnTooltip(" + show + ") to " + targetFSM.gameObject.name + "/" + targetFSM.FsmName); } Fsm.EventData.BoolData = show; currentTouch = UICamera.currentTouch; FireNGUIPlayMakerEvent(NGuiPlayMakerDelegates.OnTooltipEvent); }
void OnSelect(bool selected) { if (!enabled || targetFSM == null) { return; } if (debug) { Debug.Log("NGuiEventsToPlaymakerFsmEvents OnSelect(" + selected + ") to " + targetFSM.gameObject.name + "/" + targetFSM.FsmName); } Fsm.EventData.BoolData = selected; currentTouch = UICamera.currentTouch; FireNGUIPlayMakerEvent(NGuiPlayMakerDelegates.OnSelectEvent); }
void OnClick() { if (!enabled || targetFSM == null) { return; } _usage[(int)NGuiPlayMakerDelegates.OnClickEvent]++; if (debug) { Debug.Log("NGuiEventsToPlaymakerFsmEvents OnClick() " + _usage[(int)NGuiPlayMakerDelegates.OnClickEvent] + " to " + targetFSM.gameObject.name + "/" + targetFSM.FsmName); } currentTouch = UICamera.currentTouch; FireNGUIPlayMakerEvent(NGuiPlayMakerDelegates.OnClickEvent); }
void OnDrop(GameObject go) { if (!enabled || targetFSM == null) { return; } if (debug) { UnityEngine.Debug.Log("NGuiEventsToPlaymakerFsmEvents OnDrop(" + go.name + ") to " + targetFSM.gameObject.name + "/" + targetFSM.FsmName); } Fsm.EventData.GameObjectData = go; currentTouch = UICamera.currentTouch; FireNGUIPlayMakerEvent(NGuiPlayMakerDelegates.OnDropEvent); }
void OnHover(bool isOver) { if (!enabled || targetFSM == null) { return; } _usage[(int)NGuiPlayMakerDelegates.OnHoverEvent]++; if (debug) { UnityEngine.Debug.Log("NGuiEventsToPlaymakerFsmEvents OnHover(" + isOver + ") " + _usage[(int)NGuiPlayMakerDelegates.OnClickEvent] + " to " + targetFSM.gameObject.name + "/" + targetFSM.FsmName, this); } Fsm.EventData.BoolData = isOver; currentTouch = UICamera.currentTouch; FireNGUIPlayMakerEvent(NGuiPlayMakerDelegates.OnHoverEvent); }
void OnPress(bool pressed) { if (!enabled || targetFSM == null) { return; } _usage[(int)NGuiPlayMakerDelegates.OnPressEvent]++; if (debug) { UnityEngine.Debug.Log("NGuiEventsToPlaymakerFsmEvents OnPress(" + pressed + ") " + _usage[(int)NGuiPlayMakerDelegates.OnPressEvent] + " to " + targetFSM.gameObject.name + "/" + targetFSM.FsmName); } Fsm.EventData.BoolData = pressed; currentTouch = UICamera.currentTouch; FireNGUIPlayMakerEvent(NGuiPlayMakerDelegates.OnPressEvent); }
public void ProcessOthers() { UICamera.currentTouchID = -100; UICamera.currentTouch = UICamera.controller; bool flag = false; bool flag2 = false; if (this.submitKey0 != KeyCode.None && UICamera.GetKeyDown(this.submitKey0)) { UICamera.currentKey = this.submitKey0; flag = true; } if (this.submitKey1 != KeyCode.None && UICamera.GetKeyDown(this.submitKey1)) { UICamera.currentKey = this.submitKey1; flag = true; } if (this.submitKey0 != KeyCode.None && UICamera.GetKeyUp(this.submitKey0)) { UICamera.currentKey = this.submitKey0; flag2 = true; } if (this.submitKey1 != KeyCode.None && UICamera.GetKeyUp(this.submitKey1)) { UICamera.currentKey = this.submitKey1; flag2 = true; } if (flag || flag2) { UICamera.currentScheme = UICamera.ControlScheme.Controller; UICamera.currentTouch.last = UICamera.currentTouch.current; UICamera.currentTouch.current = UICamera.mCurrentSelection; this.ProcessTouch(flag, flag2); UICamera.currentTouch.last = null; } int num = 0; int num2 = 0; if (this.useKeyboard) { if (UICamera.inputHasFocus) { num += UICamera.GetDirection(KeyCode.UpArrow, KeyCode.DownArrow); num2 += UICamera.GetDirection(KeyCode.RightArrow, KeyCode.LeftArrow); } else { num += UICamera.GetDirection(KeyCode.W, KeyCode.UpArrow, KeyCode.S, KeyCode.DownArrow); num2 += UICamera.GetDirection(KeyCode.D, KeyCode.RightArrow, KeyCode.A, KeyCode.LeftArrow); } } if (this.useController) { if (!string.IsNullOrEmpty(this.verticalAxisName)) { num += UICamera.GetDirection(this.verticalAxisName); } if (!string.IsNullOrEmpty(this.horizontalAxisName)) { num2 += UICamera.GetDirection(this.horizontalAxisName); } } if (num != 0) { UICamera.currentScheme = UICamera.ControlScheme.Controller; KeyCode keyCode = (num <= 0) ? KeyCode.DownArrow : KeyCode.UpArrow; if (UICamera.onKey != null) { UICamera.onKey(UICamera.mCurrentSelection, keyCode); } UICamera.Notify(UICamera.mCurrentSelection, "OnKey", keyCode); } if (num2 != 0) { UICamera.currentScheme = UICamera.ControlScheme.Controller; KeyCode keyCode2 = (num2 <= 0) ? KeyCode.LeftArrow : KeyCode.RightArrow; if (UICamera.onKey != null) { UICamera.onKey(UICamera.mCurrentSelection, keyCode2); } UICamera.Notify(UICamera.mCurrentSelection, "OnKey", keyCode2); } if (this.useKeyboard && UICamera.GetKeyDown(KeyCode.Tab)) { UICamera.currentKey = KeyCode.Tab; UICamera.currentScheme = UICamera.ControlScheme.Controller; if (UICamera.onKey != null) { UICamera.onKey(UICamera.mCurrentSelection, KeyCode.Tab); } UICamera.Notify(UICamera.mCurrentSelection, "OnKey", KeyCode.Tab); } if (this.cancelKey0 != KeyCode.None && UICamera.GetKeyDown(this.cancelKey0)) { UICamera.currentKey = this.cancelKey0; UICamera.currentScheme = UICamera.ControlScheme.Controller; if (UICamera.onKey != null) { UICamera.onKey(UICamera.mCurrentSelection, KeyCode.Escape); } UICamera.Notify(UICamera.mCurrentSelection, "OnKey", KeyCode.Escape); } if (this.cancelKey1 != KeyCode.None && UICamera.GetKeyDown(this.cancelKey1)) { UICamera.currentKey = this.cancelKey1; UICamera.currentScheme = UICamera.ControlScheme.Controller; if (UICamera.onKey != null) { UICamera.onKey(UICamera.mCurrentSelection, KeyCode.Escape); } UICamera.Notify(UICamera.mCurrentSelection, "OnKey", KeyCode.Escape); } UICamera.currentTouch = null; UICamera.currentKey = KeyCode.None; }
void OnTooltip(bool show) { if (!enabled || targetFSM == null) return; if (debug) Debug.Log("NGuiEventsToPlaymakerFsmEvents OnTooltip("+show+") to "+targetFSM.gameObject.name+"/"+targetFSM.FsmName); Fsm.EventData.BoolData = show; currentTouch = UICamera.currentTouch; FireNGUIPlayMakerEvent(NGuiPlayMakerDelegates.OnTooltipEvent); }
void OnDrop(GameObject go) { if (!enabled || targetFSM == null) return; if (debug) Debug.Log("NGuiEventsToPlaymakerFsmEvents OnDrop("+go.name+") to "+targetFSM.gameObject.name+"/"+targetFSM.FsmName); Fsm.EventData.GameObjectData = go; currentTouch = UICamera.currentTouch; FireNGUIPlayMakerEvent(NGuiPlayMakerDelegates.OnDropEvent); }
void OnDrag(Vector2 delta) { if (!enabled || targetFSM == null) return; if (debug) Debug.Log("NGuiEventsToPlaymakerFsmEvents OnDrag("+delta+") to "+targetFSM.gameObject.name+"/"+targetFSM.FsmName); Fsm.EventData.Vector3Data = new Vector3(delta.x, delta.y); currentTouch = UICamera.currentTouch; FireNGUIPlayMakerEvent(NGuiPlayMakerDelegates.OnDragEvent); }
void OnSelect(bool selected) { if (!enabled || targetFSM == null) return; if (debug) UnityEngine.Debug.Log("NGuiEventsToPlaymakerFsmEvents OnSelect("+selected+") to "+targetFSM.gameObject.name+"/"+targetFSM.FsmName); Fsm.EventData.BoolData = selected; currentTouch = UICamera.currentTouch; FireNGUIPlayMakerEvent(NGuiPlayMakerDelegates.OnSelectEvent); }
public void ProcessTouches() { UICamera.currentScheme = UICamera.ControlScheme.Touch; for (int i = 0; i < Input.touchCount; i++) { Touch touch = Input.GetTouch(i); UICamera.currentTouchID = ((!this.allowMultiTouch) ? 1 : touch.fingerId); UICamera.currentTouch = UICamera.GetTouch(UICamera.currentTouchID); bool flag = touch.phase == TouchPhase.Began || UICamera.currentTouch.touchBegan; bool flag2 = touch.phase == TouchPhase.Canceled || touch.phase == TouchPhase.Ended; UICamera.currentTouch.touchBegan = false; UICamera.currentTouch.delta = ((!flag) ? (touch.position - UICamera.currentTouch.pos) : Vector2.zero); UICamera.currentTouch.pos = touch.position; if (!UICamera.Raycast(UICamera.currentTouch.pos)) { UICamera.hoveredObject = UICamera.fallThrough; } if (UICamera.hoveredObject == null) { UICamera.hoveredObject = UICamera.mGenericHandler; } UICamera.currentTouch.last = UICamera.currentTouch.current; UICamera.currentTouch.current = UICamera.hoveredObject; UICamera.lastTouchPosition = UICamera.currentTouch.pos; if (flag) { UICamera.currentTouch.pressedCam = UICamera.currentCamera; } else if (UICamera.currentTouch.pressed != null) { UICamera.currentCamera = UICamera.currentTouch.pressedCam; } if (touch.tapCount > 1) { UICamera.currentTouch.clickTime = RealTime.time; } this.ProcessTouch(flag, flag2); if (flag2) { UICamera.RemoveTouch(UICamera.currentTouchID); } UICamera.currentTouch.last = null; UICamera.currentTouch = null; if (!this.allowMultiTouch) { break; } } if (Input.touchCount == 0) { if (UICamera.mUsingTouchEvents) { UICamera.mUsingTouchEvents = false; return; } if (this.useMouse) { this.ProcessMouse(); } } else { UICamera.mUsingTouchEvents = true; } }
private void ProcessFakeTouches() { bool mouseButtonDown = Input.GetMouseButtonDown(0); bool mouseButtonUp = Input.GetMouseButtonUp(0); bool mouseButton = Input.GetMouseButton(0); if (mouseButtonDown || mouseButtonUp || mouseButton) { UICamera.currentTouchID = 1; UICamera.currentTouch = UICamera.mMouse[0]; UICamera.currentTouch.touchBegan = mouseButtonDown; if (mouseButtonDown) { UICamera.currentTouch.pressTime = RealTime.time; } Vector2 vector = Input.mousePosition; UICamera.currentTouch.delta = ((!mouseButtonDown) ? (vector - UICamera.currentTouch.pos) : Vector2.zero); UICamera.currentTouch.pos = vector; if (!UICamera.Raycast(UICamera.currentTouch.pos)) { UICamera.hoveredObject = UICamera.fallThrough; } if (UICamera.hoveredObject == null) { UICamera.hoveredObject = UICamera.mGenericHandler; } UICamera.currentTouch.last = UICamera.currentTouch.current; UICamera.currentTouch.current = UICamera.hoveredObject; UICamera.lastTouchPosition = UICamera.currentTouch.pos; if (mouseButtonDown) { UICamera.currentTouch.pressedCam = UICamera.currentCamera; } else if (UICamera.currentTouch.pressed != null) { UICamera.currentCamera = UICamera.currentTouch.pressedCam; } this.ProcessTouch(mouseButtonDown, mouseButtonUp); if (mouseButtonUp) { UICamera.RemoveTouch(UICamera.currentTouchID); } UICamera.currentTouch.last = null; UICamera.currentTouch = null; } }
void OnHover(bool isOver) { if (!enabled || targetFSM == null) return; _usage[(int)NGuiPlayMakerDelegates.OnHoverEvent] ++; // if (debug) Debug.Log("NGuiEventsToPlaymakerFsmEvents OnHover("+isOver+") "+_usage[(int)NGuiPlayMakerDelegates.OnClickEvent]+" to "+targetFSM.gameObject.name+"/"+targetFSM.FsmName,this); Fsm.EventData.BoolData = isOver; currentTouch = UICamera.currentTouch; FireNGUIPlayMakerEvent(NGuiPlayMakerDelegates.OnHoverEvent); if (isOver) { targetFSM.SendEvent(NGuiPlayMakerProxy.GetFsmEventEnumValue(NGuiPlayMakerDelegates.OnHoverEvent) + " ENTER"); }else{ targetFSM.SendEvent(NGuiPlayMakerProxy.GetFsmEventEnumValue(NGuiPlayMakerDelegates.OnHoverEvent) + " EXIT"); } }
public void ProcessMouse() { UICamera.lastTouchPosition = Input.mousePosition; UICamera.mMouse[0].delta = UICamera.lastTouchPosition - UICamera.mMouse[0].pos; UICamera.mMouse[0].pos = UICamera.lastTouchPosition; bool flag = UICamera.mMouse[0].delta.sqrMagnitude > 0.001f; for (int i = 1; i < 3; i++) { UICamera.mMouse[i].pos = UICamera.mMouse[0].pos; UICamera.mMouse[i].delta = UICamera.mMouse[0].delta; } bool flag2 = false; bool flag3 = false; for (int j = 0; j < 3; j++) { if (Input.GetMouseButtonDown(j)) { UICamera.currentScheme = UICamera.ControlScheme.Mouse; flag3 = true; flag2 = true; } else if (Input.GetMouseButton(j)) { UICamera.currentScheme = UICamera.ControlScheme.Mouse; flag2 = true; } } if (flag2 || flag || this.mNextRaycast < RealTime.time) { this.mNextRaycast = RealTime.time + 0.02f; if (!UICamera.Raycast(Input.mousePosition)) { UICamera.hoveredObject = UICamera.fallThrough; } if (UICamera.hoveredObject == null) { UICamera.hoveredObject = UICamera.mGenericHandler; } for (int k = 0; k < 3; k++) { UICamera.mMouse[k].current = UICamera.hoveredObject; } } bool flag4 = UICamera.mMouse[0].last != UICamera.mMouse[0].current; if (flag4) { UICamera.currentScheme = UICamera.ControlScheme.Mouse; } if (flag2) { this.mTooltipTime = 0f; } else if (flag && (!this.stickyTooltip || flag4)) { if (this.mTooltipTime != 0f) { this.mTooltipTime = RealTime.time + this.tooltipDelay; } else if (this.mTooltip != null) { this.ShowTooltip(false); } } if (flag && UICamera.onMouseMove != null) { UICamera.currentTouch = UICamera.mMouse[0]; UICamera.onMouseMove(UICamera.currentTouch.delta); UICamera.currentTouch = null; } if ((flag3 || !flag2) && UICamera.mHover != null && flag4) { UICamera.currentScheme = UICamera.ControlScheme.Mouse; UICamera.currentTouch = UICamera.mMouse[0]; if (this.mTooltip != null) { this.ShowTooltip(false); } if (UICamera.onHover != null) { UICamera.onHover(UICamera.mHover, false); } UICamera.Notify(UICamera.mHover, "OnHover", false); UICamera.mHover = null; } for (int l = 0; l < 3; l++) { bool mouseButtonDown = Input.GetMouseButtonDown(l); bool mouseButtonUp = Input.GetMouseButtonUp(l); if (mouseButtonDown || mouseButtonUp) { UICamera.currentScheme = UICamera.ControlScheme.Mouse; } UICamera.currentTouch = UICamera.mMouse[l]; UICamera.currentTouchID = -1 - l; UICamera.currentKey = KeyCode.Mouse0 + l; if (mouseButtonDown) { UICamera.currentTouch.pressedCam = UICamera.currentCamera; } else if (UICamera.currentTouch.pressed != null) { UICamera.currentCamera = UICamera.currentTouch.pressedCam; } this.ProcessTouch(mouseButtonDown, mouseButtonUp); UICamera.currentKey = KeyCode.None; } if (!flag2 && flag4) { UICamera.currentScheme = UICamera.ControlScheme.Mouse; this.mTooltipTime = RealTime.time + this.tooltipDelay; UICamera.mHover = UICamera.mMouse[0].current; UICamera.currentTouch = UICamera.mMouse[0]; if (UICamera.onHover != null) { UICamera.onHover(UICamera.mHover, true); } UICamera.Notify(UICamera.mHover, "OnHover", true); } UICamera.currentTouch = null; UICamera.mMouse[0].last = UICamera.mMouse[0].current; for (int m = 1; m < 3; m++) { UICamera.mMouse[m].last = UICamera.mMouse[0].last; } }
public static UICamera.MouseOrTouch GetTouch(int id) { UICamera.MouseOrTouch mouseOrTouch = null; if (id < 0) { return UICamera.GetMouse(-id - 1); } if (!UICamera.mTouches.TryGetValue(id, out mouseOrTouch)) { mouseOrTouch = new UICamera.MouseOrTouch(); mouseOrTouch.pressTime = RealTime.time; mouseOrTouch.touchBegan = true; UICamera.mTouches.Add(id, mouseOrTouch); } return mouseOrTouch; }
void OnClick() { if (!enabled || targetFSM == null) return; _usage[(int)NGuiPlayMakerDelegates.OnClickEvent] ++; if (debug) Debug.Log("NGuiEventsToPlaymakerFsmEvents OnClick() "+_usage[(int)NGuiPlayMakerDelegates.OnClickEvent]+" to "+targetFSM.gameObject.name+"/"+targetFSM.FsmName); currentTouch = UICamera.currentTouch; FireNGUIPlayMakerEvent(NGuiPlayMakerDelegates.OnClickEvent); }
private void OnApplicationPause() { UICamera.MouseOrTouch mouseOrTouch = UICamera.currentTouch; if (this.useTouch) { BetterList<int> betterList = new BetterList<int>(); foreach (KeyValuePair<int, UICamera.MouseOrTouch> keyValuePair in UICamera.mTouches) { if (keyValuePair.Value != null && keyValuePair.Value.pressed) { UICamera.currentTouch = keyValuePair.Value; UICamera.currentTouchID = keyValuePair.Key; UICamera.currentScheme = UICamera.ControlScheme.Touch; UICamera.currentTouch.clickNotification = UICamera.ClickNotification.None; this.ProcessTouch(false, true); betterList.Add(UICamera.currentTouchID); } } for (int i = 0; i < betterList.size; i++) { UICamera.RemoveTouch(betterList[i]); } } if (this.useMouse) { for (int j = 0; j < 3; j++) { if (UICamera.mMouse[j].pressed) { UICamera.currentTouch = UICamera.mMouse[j]; UICamera.currentTouchID = -1 - j; UICamera.currentKey = KeyCode.Mouse0 + j; UICamera.currentScheme = UICamera.ControlScheme.Mouse; UICamera.currentTouch.clickNotification = UICamera.ClickNotification.None; this.ProcessTouch(false, true); } } } if (this.useController && UICamera.controller.pressed) { UICamera.currentTouch = UICamera.controller; UICamera.currentTouchID = -100; UICamera.currentScheme = UICamera.ControlScheme.Controller; UICamera.currentTouch.last = UICamera.currentTouch.current; UICamera.currentTouch.current = UICamera.mCurrentSelection; UICamera.currentTouch.clickNotification = UICamera.ClickNotification.None; this.ProcessTouch(false, true); UICamera.currentTouch.last = null; } UICamera.currentTouch = mouseOrTouch; }
void OnHover(bool isOver) { if (!enabled || targetFSM == null) return; _usage[(int)NGuiPlayMakerDelegates.OnHoverEvent] ++; if (debug) Debug.Log("NGuiEventsToPlaymakerFsmEvents OnHover("+isOver+") "+_usage[(int)NGuiPlayMakerDelegates.OnClickEvent]+" to "+targetFSM.gameObject.name+"/"+targetFSM.FsmName); Fsm.EventData.BoolData = isOver; currentTouch = UICamera.currentTouch; FireNGUIPlayMakerEvent(NGuiPlayMakerDelegates.OnHoverEvent); if (isOver) { FireNGUIPlayMakerEvent(NGuiPlayMakerDelegates.OnHoverEventEnter); _usage[(int)NGuiPlayMakerDelegates.OnHoverEventEnter] ++; }else{ FireNGUIPlayMakerEvent(NGuiPlayMakerDelegates.OnHoverEventExit); _usage[(int)NGuiPlayMakerDelegates.OnHoverEventExit] ++; } }
void OnPress(bool pressed) { if (!enabled || targetFSM == null) return; _usage[(int)NGuiPlayMakerDelegates.OnPressEvent] ++; if (debug) Debug.Log("NGuiEventsToPlaymakerFsmEvents OnPress("+pressed+") "+_usage[(int)NGuiPlayMakerDelegates.OnPressEvent]+" to "+targetFSM.gameObject.name+"/"+targetFSM.FsmName); Fsm.EventData.BoolData = pressed; currentTouch = UICamera.currentTouch; FireNGUIPlayMakerEvent(NGuiPlayMakerDelegates.OnPressEvent); if (pressed) { FireNGUIPlayMakerEvent(NGuiPlayMakerDelegates.OnPressEventDown); _usage[(int)NGuiPlayMakerDelegates.OnPressEventDown] ++; }else{ FireNGUIPlayMakerEvent(NGuiPlayMakerDelegates.OnPressEventUp); _usage[(int)NGuiPlayMakerDelegates.OnPressEventUp] ++; } }
/// <summary> /// Start the dragging operation. /// </summary> protected virtual void StartDragging () { if (!interactable) return; if (!mDragging) { if (cloneOnDrag) { mPressed = false; GameObject clone = NGUITools.AddChild(transform.parent.gameObject, gameObject); clone.transform.localPosition = transform.localPosition; clone.transform.localRotation = transform.localRotation; clone.transform.localScale = transform.localScale; UIButtonColor bc = clone.GetComponent<UIButtonColor>(); if (bc != null) bc.defaultColor = GetComponent<UIButtonColor>().defaultColor; if (mTouch != null && mTouch.pressed == gameObject) { mTouch.current = clone; mTouch.pressed = clone; mTouch.dragged = clone; mTouch.last = clone; } UIDragDropItem item = clone.GetComponent<UIDragDropItem>(); item.mTouch = mTouch; item.mPressed = true; item.mDragging = true; item.Start(); item.OnDragDropStart(); if (UICamera.currentTouch == null) UICamera.currentTouch = mTouch; mTouch = null; UICamera.Notify(gameObject, "OnPress", false); UICamera.Notify(gameObject, "OnHover", false); } else { mDragging = true; OnDragDropStart(); } } }
protected virtual void OnPress(bool isPressed) { if (!this.interactable || UICamera.currentTouchID == -2 || UICamera.currentTouchID == -3) { return; } if (isPressed) { if (!this.mPressed) { this.mTouch = UICamera.currentTouch; this.mDragStartTime = RealTime.time + this.pressAndHoldDelay; this.mPressed = true; } } else if (this.mPressed && this.mTouch == UICamera.currentTouch) { this.mPressed = false; this.mTouch = null; } }
void OnPress(bool pressed) { if (!enabled || targetFSM == null) return; _usage[(int)NGuiPlayMakerDelegates.OnPressEvent] ++; // if (debug) Debug.Log("NGuiEventsToPlaymakerFsmEvents OnPress("+pressed+") "+_usage[(int)NGuiPlayMakerDelegates.OnPressEvent]+" to "+targetFSM.gameObject.name+"/"+targetFSM.FsmName); Fsm.EventData.BoolData = pressed; currentTouch = UICamera.currentTouch; FireNGUIPlayMakerEvent(NGuiPlayMakerDelegates.OnPressEvent); if (pressed) { targetFSM.SendEvent(NGuiPlayMakerProxy.GetFsmEventEnumValue(NGuiPlayMakerDelegates.OnPressEvent) + " DOWN"); }else{ targetFSM.SendEvent(NGuiPlayMakerProxy.GetFsmEventEnumValue(NGuiPlayMakerDelegates.OnPressEvent) + " UP"); } }
/// <summary> /// Record the time the item was pressed on. /// </summary> protected virtual void OnPress (bool isPressed) { if (!interactable) return; if (isPressed) { mTouch = UICamera.currentTouch; mDragStartTime = RealTime.time + pressAndHoldDelay; mPressed = true; } else { mPressed = false; mTouch = null; } }
public virtual void StartDragging() { if (!this.interactable) { return; } if (!this.mDragging) { if (this.cloneOnDrag) { this.mPressed = false; GameObject gameObject = NGUITools.AddChild(base.transform.parent.gameObject, base.gameObject); gameObject.transform.localPosition = base.transform.localPosition; gameObject.transform.localRotation = base.transform.localRotation; gameObject.transform.localScale = base.transform.localScale; UIButtonColor component = gameObject.GetComponent<UIButtonColor>(); if (component != null) { component.defaultColor = base.GetComponent<UIButtonColor>().defaultColor; } if (this.mTouch != null && this.mTouch.pressed == base.gameObject) { this.mTouch.current = gameObject; this.mTouch.pressed = gameObject; this.mTouch.dragged = gameObject; this.mTouch.last = gameObject; } UIDragDropItem component2 = gameObject.GetComponent<UIDragDropItem>(); component2.mTouch = this.mTouch; component2.mPressed = true; component2.mDragging = true; component2.Start(); component2.OnDragDropStart(); if (UICamera.currentTouch == null) { UICamera.currentTouch = this.mTouch; } this.mTouch = null; UICamera.Notify(base.gameObject, "OnPress", false); UICamera.Notify(base.gameObject, "OnHover", false); } else { this.mDragging = true; this.OnDragDropStart(); } } }