public override void OnInput(POINTER_INFO ptr) { if (!this.m_controlIsEnabled) { return; } if (this.inputDelegate != null) { this.inputDelegate(ref ptr); } this.lastPtrType = ptr.type; POINTER_INFO.INPUT_EVENT evt = ptr.evt; switch (evt) { case POINTER_INFO.INPUT_EVENT.TAP: this.PanelClicked(ptr); goto IL_104; case POINTER_INFO.INPUT_EVENT.RIGHT_TAP: case POINTER_INFO.INPUT_EVENT.LONG_TAP: case POINTER_INFO.INPUT_EVENT.MOVE: IL_59: if (evt != POINTER_INFO.INPUT_EVENT.PRESS) { goto IL_104; } if (!this.requireTap) { this.PanelClicked(ptr); } goto IL_104; case POINTER_INFO.INPUT_EVENT.MOVE_OFF: case POINTER_INFO.INPUT_EVENT.RELEASE_OFF: if (base.collider != null) { RaycastHit raycastHit; if (base.collider.Raycast(ptr.ray, out raycastHit, ptr.rayDepth)) { if (ptr.evt == POINTER_INFO.INPUT_EVENT.MOVE_OFF) { ptr.evt = POINTER_INFO.INPUT_EVENT.MOVE; } else { ptr.evt = POINTER_INFO.INPUT_EVENT.RELEASE; } } else if (this.dismissOnMoveOff && this.m_panelState == UIBistateInteractivePanel.STATE.SHOWING) { this.SetPanelState(UIBistateInteractivePanel.STATE.HIDDEN); } } goto IL_104; } goto IL_59; IL_104: base.OnInput(ptr); }
// Switches the displayed sprite(s) to match the current state: protected void SetPanelState(STATE s) { // If this is the same as the current state, ignore: if (m_panelState == s) { return; } m_panelState = s; // See if we need to set/unset our listeners // for outside clicks: if (dismissOnPeerClick || dismissOnOutsideClick) { if (m_panelState == STATE.SHOWING) { if ((lastPtrType & POINTER_INFO.POINTER_TYPE.MOUSE_TOUCHPAD) == lastPtrType) { UIManager.instance.AddMouseTouchPtrListener(ClickListener); lastListenerType = POINTER_INFO.POINTER_TYPE.MOUSE_TOUCHPAD; } else { UIManager.instance.AddRayPtrListener(ClickListener); lastListenerType = POINTER_INFO.POINTER_TYPE.MOUSE_TOUCHPAD; } } else // Unset our listener: { if ((lastListenerType & POINTER_INFO.POINTER_TYPE.MOUSE_TOUCHPAD) == lastListenerType) { UIManager.instance.RemoveMouseTouchPtrListener(ClickListener); } else { UIManager.instance.RemoveRayPtrListener(ClickListener); } } } // Start a new transition: if (m_panelState == STATE.SHOWING) { base.StartTransition(UIPanelManager.SHOW_MODE.BringInForward); } else { base.StartTransition(UIPanelManager.SHOW_MODE.DismissForward); } // Call the state change delegate if (stateChangeDel != null) { stateChangeDel(m_panelState); } }
protected void SetPanelState(UIBistateInteractivePanel.STATE s) { if (this.m_panelState == s) { return; } this.m_panelState = s; if (this.dismissOnPeerClick || this.dismissOnOutsideClick) { if (this.m_panelState == UIBistateInteractivePanel.STATE.SHOWING) { if ((this.lastPtrType & POINTER_INFO.POINTER_TYPE.MOUSE_TOUCHPAD) == this.lastPtrType) { NrTSingleton <UIManager> .Instance.AddMouseTouchPtrListener(new UIManager.PointerInfoDelegate(this.ClickListener)); this.lastListenerType = POINTER_INFO.POINTER_TYPE.MOUSE_TOUCHPAD; } else { NrTSingleton <UIManager> .Instance.AddRayPtrListener(new UIManager.PointerInfoDelegate(this.ClickListener)); this.lastListenerType = POINTER_INFO.POINTER_TYPE.MOUSE_TOUCHPAD; } } else if ((this.lastListenerType & POINTER_INFO.POINTER_TYPE.MOUSE_TOUCHPAD) == this.lastListenerType) { NrTSingleton <UIManager> .Instance.RemoveMouseTouchPtrListener(new UIManager.PointerInfoDelegate(this.ClickListener)); } else { NrTSingleton <UIManager> .Instance.RemoveRayPtrListener(new UIManager.PointerInfoDelegate(this.ClickListener)); } } if (this.m_panelState == UIBistateInteractivePanel.STATE.SHOWING) { base.StartTransition(UIPanelManager.SHOW_MODE.BringInForward); } else { base.StartTransition(UIPanelManager.SHOW_MODE.DismissForward); } }
public void Copy(POINTER_INFO ptr) { this.type = ptr.type; this.camera = ptr.camera; this.id = ptr.id; this.fingerID = ptr.fingerID; this.actionID = ptr.actionID; this.evt = ptr.evt; this.active = ptr.active; this.devicePos = ptr.devicePos; this.origPos = ptr.origPos; this.inputDelta = ptr.inputDelta; this.ray = ptr.ray; this.prevRay = ptr.prevRay; this.rayDepth = ptr.rayDepth; this.isTap = ptr.isTap; this.targetObj = ptr.targetObj; this.layerMask = ptr.layerMask; this.hitInfo = ptr.hitInfo; this.clickTime = ptr.clickTime; }
// Switches the displayed sprite(s) to match the current state: protected void SetPanelState(STATE s) { // If this is the same as the current state, ignore: if (m_panelState == s) return; m_panelState = s; // See if we need to set/unset our listeners // for outside clicks: if (dismissOnPeerClick || dismissOnOutsideClick) { if (m_panelState == STATE.SHOWING) { if ((lastPtrType & POINTER_INFO.POINTER_TYPE.MOUSE_TOUCHPAD) == lastPtrType) { UIManager.instance.AddMouseTouchPtrListener(ClickListener); lastListenerType = POINTER_INFO.POINTER_TYPE.MOUSE_TOUCHPAD; } else { UIManager.instance.AddRayPtrListener(ClickListener); lastListenerType = POINTER_INFO.POINTER_TYPE.MOUSE_TOUCHPAD; } } else // Unset our listener: { if ((lastListenerType & POINTER_INFO.POINTER_TYPE.MOUSE_TOUCHPAD) == lastListenerType) { UIManager.instance.RemoveMouseTouchPtrListener(ClickListener); } else { UIManager.instance.RemoveRayPtrListener(ClickListener); } } } // Start a new transition: if(m_panelState == STATE.SHOWING) base.StartTransition(UIPanelManager.SHOW_MODE.BringInForward); else base.StartTransition(UIPanelManager.SHOW_MODE.DismissForward); // Call the state change delegate if (stateChangeDel != null) stateChangeDel(m_panelState); }
//--------------------------------------------------- // Input handling: //--------------------------------------------------- public override void OnInput(POINTER_INFO ptr) { if (!m_controlIsEnabled) return; if (inputDelegate != null) inputDelegate(ref ptr); lastPtrType = ptr.type; // Only check for out-of-viewport input if such is possible // (i.e. if we aren't on a hardware device where it is // impossible to have input outside the viewport) #if UNITY_EDITOR || !(UNITY_IPHONE || UNITY_ANDROID) // See if the input should be considered a move-off // because it is outside the viewport: if(dismissOnMoveOff) { if (ptr.devicePos.x < 0 || ptr.devicePos.y < 0 || ptr.devicePos.x > ptr.camera.pixelWidth || ptr.devicePos.y > ptr.camera.pixelHeight) { // Interpret this as a move-off if (m_panelState == STATE.SHOWING) Hide(); return; } } #endif // Change the state if necessary: switch (ptr.evt) { case POINTER_INFO.INPUT_EVENT.PRESS: if (!requireTap) PanelClicked(ptr); break; case POINTER_INFO.INPUT_EVENT.TAP: PanelClicked(ptr); break; /* case POINTER_INFO.INPUT_EVENT.MOVE_OFF: // Check to see if we are still under // the pointer and one of our child // controls is just catching the hit // instead: RaycastHit hit; if (collider != null) { if (collider.Raycast(ptr.ray, out hit, ptr.rayDepth)) { // Change the event to a MOVE so that any // parent panel doesn't try its own raycast // and fail since the pointer is over us // instead: ptr.evt = POINTER_INFO.INPUT_EVENT.MOVE; } } break; */ case POINTER_INFO.INPUT_EVENT.MOVE_OFF: case POINTER_INFO.INPUT_EVENT.RELEASE_OFF: // Do a raycast to see if we're // still under the pointer and one of // our child controls is just catching // the hit instead: RaycastHit hit; if (collider != null) { if (collider.Raycast(ptr.ray, out hit, ptr.rayDepth)) { if (ptr.evt == POINTER_INFO.INPUT_EVENT.MOVE_OFF) { // Change the event to a MOVE so that any // parent panel doesn't try its own raycast // and fail since the pointer is over us // instead: ptr.evt = POINTER_INFO.INPUT_EVENT.MOVE; } else { ptr.evt = POINTER_INFO.INPUT_EVENT.RELEASE; } } else { if(dismissOnMoveOff) { if (m_panelState == STATE.SHOWING) SetPanelState(STATE.HIDDEN); } } } break; } base.OnInput(ptr); }
//--------------------------------------------------- // Input handling: //--------------------------------------------------- public override void OnInput(POINTER_INFO ptr) { if (!m_controlIsEnabled) { return; } if (inputDelegate != null) { inputDelegate(ref ptr); } lastPtrType = ptr.type; // Only check for out-of-viewport input if such is possible // (i.e. if we aren't on a hardware device where it is // impossible to have input outside the viewport) #if UNITY_EDITOR || !(UNITY_IPHONE || UNITY_ANDROID) // See if the input should be considered a move-off // because it is outside the viewport: if (dismissOnMoveOff) { if (ptr.devicePos.x < 0 || ptr.devicePos.y < 0 || ptr.devicePos.x > ptr.camera.pixelWidth || ptr.devicePos.y > ptr.camera.pixelHeight) { // Interpret this as a move-off if (m_panelState == STATE.SHOWING) { Hide(); } return; } } #endif // Change the state if necessary: switch (ptr.evt) { case POINTER_INFO.INPUT_EVENT.PRESS: if (!requireTap) { PanelClicked(ptr); } break; case POINTER_INFO.INPUT_EVENT.TAP: PanelClicked(ptr); break; /* * case POINTER_INFO.INPUT_EVENT.MOVE_OFF: * // Check to see if we are still under * // the pointer and one of our child * // controls is just catching the hit * // instead: * RaycastHit hit; * if (collider != null) * { * if (collider.Raycast(ptr.ray, out hit, ptr.rayDepth)) * { * // Change the event to a MOVE so that any * // parent panel doesn't try its own raycast * // and fail since the pointer is over us * // instead: * ptr.evt = POINTER_INFO.INPUT_EVENT.MOVE; * } * } * break; */ case POINTER_INFO.INPUT_EVENT.MOVE_OFF: case POINTER_INFO.INPUT_EVENT.RELEASE_OFF: // Do a raycast to see if we're // still under the pointer and one of // our child controls is just catching // the hit instead: RaycastHit hit; if (GetComponent <Collider>() != null) { if (GetComponent <Collider>().Raycast(ptr.ray, out hit, ptr.rayDepth)) { if (ptr.evt == POINTER_INFO.INPUT_EVENT.MOVE_OFF) { // Change the event to a MOVE so that any // parent panel doesn't try its own raycast // and fail since the pointer is over us // instead: ptr.evt = POINTER_INFO.INPUT_EVENT.MOVE; } else { ptr.evt = POINTER_INFO.INPUT_EVENT.RELEASE; } } else { if (dismissOnMoveOff) { if (m_panelState == STATE.SHOWING) { SetPanelState(STATE.HIDDEN); } } } } break; } base.OnInput(ptr); }
//--------------------------------------------------- // Input handling: //--------------------------------------------------- public override void OnInput(POINTER_INFO ptr) { if (!m_controlIsEnabled) return; if (inputDelegate != null) inputDelegate(ref ptr); lastPtrType = ptr.type; // Change the state if necessary: switch (ptr.evt) { case POINTER_INFO.INPUT_EVENT.PRESS: if (!requireTap) PanelClicked(ptr); break; case POINTER_INFO.INPUT_EVENT.TAP: PanelClicked(ptr); break; /* case POINTER_INFO.INPUT_EVENT.MOVE_OFF: // Check to see if we are still under // the pointer and one of our child // controls is just catching the hit // instead: RaycastHit hit; if (collider != null) { if (collider.Raycast(ptr.ray, out hit, ptr.rayDepth)) { // Change the event to a MOVE so that any // parent panel doesn't try its own raycast // and fail since the pointer is over us // instead: ptr.evt = POINTER_INFO.INPUT_EVENT.MOVE; } } break; */ case POINTER_INFO.INPUT_EVENT.MOVE_OFF: case POINTER_INFO.INPUT_EVENT.RELEASE_OFF: // Do a raycast to see if we're // still under the pointer and one of // our child controls is just catching // the hit instead: RaycastHit hit; if (collider != null) { if (collider.Raycast(ptr.ray, out hit, ptr.rayDepth)) { if (ptr.evt == POINTER_INFO.INPUT_EVENT.MOVE_OFF) { // Change the event to a MOVE so that any // parent panel doesn't try its own raycast // and fail since the pointer is over us // instead: ptr.evt = POINTER_INFO.INPUT_EVENT.MOVE; } else { ptr.evt = POINTER_INFO.INPUT_EVENT.RELEASE; } } else { if(dismissOnMoveOff) { if (m_panelState == STATE.SHOWING) SetPanelState(STATE.HIDDEN); } } } break; } base.OnInput(ptr); }