static public int constructor(IntPtr l) { try { FairyGUI.HitTestContext o; o = new FairyGUI.HitTestContext(); pushValue(l, true); pushValue(l, o); return(2); } catch (Exception e) { return(error(l, e)); } }
void GetHitTarget() { if (_frameGotHitTarget == Time.frameCount) { return; } _frameGotHitTarget = Time.frameCount; if (_customInput) { Vector2 pos = _customInputPos; pos.y = stageHeight - pos.y; TouchInfo touch = _touches[0]; _touchTarget = HitTest(pos, true); touch.target = _touchTarget; } else if (touchScreen) { _touchTarget = null; for (int i = 0; i < Input.touchCount; ++i) { Touch uTouch = Input.GetTouch(i); Vector2 pos = uTouch.position; pos.y = stageHeight - pos.y; TouchInfo touch = null; TouchInfo free = null; for (int j = 0; j < 5; j++) { if (_touches[j].touchId == uTouch.fingerId) { touch = _touches[j]; break; } if (_touches[j].touchId == -1) { free = _touches[j]; } } if (touch == null) { touch = free; if (touch == null || uTouch.phase != TouchPhase.Began) { continue; } touch.touchId = uTouch.fingerId; } if (uTouch.phase == TouchPhase.Stationary) { _touchTarget = touch.target; } else { _touchTarget = HitTest(pos, true); touch.target = _touchTarget; } } } else { Vector2 pos; int displayIndex; #if (UNITY_5 || UNITY_5_3_OR_NEWER) if (Display.displays.Length > 1) { Vector3 p = Display.RelativeMouseAt(Input.mousePosition); pos = p; displayIndex = (int)p.z; pos.y = Display.displays[displayIndex].renderingHeight - pos.y; } else #endif { pos = Input.mousePosition; pos.y = stageHeight - pos.y; displayIndex = -1; } TouchInfo touch = _touches[0]; if (pos.x < 0 || pos.y < 0) //outside of the window { _touchTarget = this; } else { _touchTarget = HitTest(pos, true, displayIndex); } touch.target = _touchTarget; } HitTestContext.ClearRaycastHitCache(); }
void GetHitTarget() { if (_frameGotHitTarget == Time.frameCount) { return; } _frameGotHitTarget = Time.frameCount; if (_customInput) { Vector2 pos = _customInputPos; pos.y = stageHeight - pos.y; TouchInfo touch = _touches[0]; _touchTarget = HitTest(pos, true); touch.target = _touchTarget; } else if (touchScreen) { _touchTarget = null; for (int i = 0; i < Input.touchCount; ++i) { Touch uTouch = Input.GetTouch(i); Vector2 pos = uTouch.position; pos.y = stageHeight - pos.y; TouchInfo touch = null; TouchInfo free = null; for (int j = 0; j < 5; j++) { if (_touches[j].touchId == uTouch.fingerId) { touch = _touches[j]; break; } if (_touches[j].touchId == -1) { free = _touches[j]; } } if (touch == null) { touch = free; if (touch == null || uTouch.phase != TouchPhase.Began) { continue; } touch.touchId = uTouch.fingerId; } if (uTouch.phase == TouchPhase.Stationary) { _touchTarget = touch.target; } else { _touchTarget = HitTest(pos, true); touch.target = _touchTarget; } } } else { Vector2 pos = Input.mousePosition; pos.y = stageHeight - pos.y; TouchInfo touch = _touches[0]; if (pos.x < 0 || pos.y < 0) //outside of the window { _touchTarget = this; } else { _touchTarget = HitTest(pos, true); } touch.target = _touchTarget; } HitTestContext.ClearRaycastHitCache(); }
void GetHitTarget() { if (_frameGotHitTarget == Time.frameCount) { return; } _frameGotHitTarget = Time.frameCount; if (_customInput) { Vector2 pos = _customInputPos; pos.y = stageHeight - pos.y; TouchInfo touch = _touches[0]; if (touch.x != pos.x || touch.y != pos.y || _customInputButtonDown) { _touchTarget = HitTest(pos, true); touch.target = _touchTarget; } } else if (touchScreen) { for (int i = 0; i < Input.touchCount; ++i) { Touch uTouch = Input.GetTouch(i); if (uTouch.phase == TouchPhase.Stationary) { continue; } Vector2 pos = uTouch.position; pos.y = stageHeight - pos.y; TouchInfo touch = null; for (int j = 0; j < 5; j++) { if (_touches[j].touchId == uTouch.fingerId) { touch = _touches[j]; break; } if (_touches[j].touchId == -1) { touch = _touches[j]; //下面的赋值避免了touchMove在touchDown前触发 touch.x = uTouch.position.x; touch.y = stageHeight - uTouch.position.y; } } if (touch == null) { return; } touch.touchId = uTouch.fingerId; _touchTarget = HitTest(pos, true); touch.target = _touchTarget; } } else { Vector2 pos = Input.mousePosition; pos.y = stageHeight - pos.y; TouchInfo touch = _touches[0]; if (pos.x < 0 || pos.y < 0) { pos.x = touch.x; pos.y = touch.y; } if (touch.x != pos.x || touch.y != pos.y || Input.GetMouseButtonDown(0) || Input.GetMouseButtonUp(0) || Input.GetMouseButtonDown(1)) { _touchTarget = HitTest(pos, true); touch.target = _touchTarget; } } HitTestContext.ClearRaycastHitCache(); }