/// <summary> /// 更新竖直角度移动 /// </summary> private void UpdateVerticalAngle() { if (GameSceneManager.instance.CanCtrlCam() == false) { return; } if (TouchConst.TouchIng()) { return; } float axis = 0f; #if UNITY_EDITOR axis = Input.GetAxis("Mouse ScrollWheel"); #elif UNITY_IPHONE || UNITY_ANDROID || UNITY_WP8 || UNITY_WP_8_1 || UNITY_BLACKBERRY if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved) { Vector2 delta = Input.GetTouch(0).deltaPosition; axis = delta.x; } #endif mVerticalAngle += axis * mScrollFactor * 2; if (mVerticalAngle < mMinVerticalAngle) { mVerticalAngle = mMinVerticalAngle; } else if (mVerticalAngle > mMaxVerticalAngle) { mVerticalAngle = mMaxVerticalAngle; } }
private static void Update() { RaycastHit hit; if (TouchConst.TouchBegin()) { TouchConst.times = DateTime.Now; mRay = Camera.main.ScreenPointToRay(Input.mousePosition); if (IsAllow(out hit)) { mClickName = hit.collider.name; } } if (TouchConst.TouchEnd()) { if (IsAllow(out hit)) { if (hit.collider.name.Contains(mClickName)) { mClickName = string.Empty; Debug.Log(hit.point); } } } else if (TouchConst.TouchIng()) { } else if (Input.touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Moved) { } }
// Update is called once per frame private void TouchUpdate() { if (TouchConst.TouchEnd()) { RaycastHit hit; Ray ray = mCamera.ScreenPointToRay(TouchConst.TouchPosition()); Debug.DrawLine(ray.origin, mTrans.position, Color.red, 2); if (Physics.Raycast(ray, out hit))//射线发出并碰撞到外壳,那么手臂就应该朝向碰撞点 { GameObject gameObject = hit.collider.gameObject; Debug.DrawLine(ray.origin, new Vector3(Input.mousePosition.x, Input.mousePosition.y, 100), Color.red, 2); DispatchTouchEvent(gameObject.transform); } /** * RaycastHit objhit; * //Ray ray = _uiCamera.ScreenPointToRay(Input.mousePosition); * Vector3 originPos = mTrans.position; * originPos.z -= 1; * Ray ray = new Ray(originPos, Vector3.forward); * Debug.DrawLine(ray.origin, Vector3.forward, Color.red, 2); * if (Physics.Raycast(ray, out objhit) == true) * { * GameObject gameObject = objhit.collider.gameObject; * Debug.DrawLine(ray.origin, new Vector3(Input.mousePosition.x, Input.mousePosition.y, 100), Color.red, 2); * DispatchTouchEvent(gameObject.transform); * } */ } }
private void OnLoadMABMComplete() { TempMgr.Init(); CameraMgr.Init(); TouchConst.Init(); UIMgr.Init(); GlobalInit(); }
private void OnUpate() { if (!mLArea) { return; } if (!mAreaBg) { return; } if (!mCircle) { return; } Vector2 inputPos = TouchConst.TouchPosition(); if (!mIsClickArea && TouchConst.TouchBegin()) { if (inputPos.x >= 0 && inputPos.x < Offset.x * 2 && inputPos.y > 0 && inputPos.y < Offset.y * 2) { mIsClickArea = true; } } if (!mIsClickArea) { return; } if (TouchConst.TouchIng()) { KeyboardControl.IsRestrict = true; if (!mLArea.gameObject.activeSelf) { mLArea.gameObject.SetActive(true); } UpdateAreaBgPos(inputPos); UpdateCirclePos(inputPos); //UnitMgr.Instance.SetPlayerMove(true); //if (mPlayer != null) // RemoteControl.Instance.ExecuteMove(mPlayer.CTemp.id); } else if (TouchConst.TouchEnd()) { //if(mPlayer != null) // RemoteControl.Instance.UndoMove(mPlayer.CTemp.id); //UnitMgr.Instance.SetPlayerMove(false); mIsFixedPos = false; mIsClickArea = false; if (mLArea.gameObject.activeSelf) { mLArea.gameObject.SetActive(false); } KeyboardControl.IsRestrict = false; } }
private void OnUpate() { if (!mLArea) { return; } if (!mAreaBg) { return; } if (!mCircle) { return; } Vector2 inputPos = TouchConst.TouchPosition(); if (!mIsClickArea && TouchConst.TouchBegin()) { if (inputPos.x >= 0 && inputPos.x < Offset.x * 2 && inputPos.y > 0 && inputPos.y < Offset.y * 2) { mIsClickArea = true; } } if (!mIsClickArea) { return; } if (TouchConst.TouchIng()) { if (!mLArea.gameObject.activeSelf) { mLArea.gameObject.SetActive(true); } UpdateAreaBgPos(inputPos); UpdateCirclePos(inputPos); } else { mIsFixedPos = false; mIsClickArea = false; if (mLArea.gameObject.activeSelf) { mLArea.gameObject.SetActive(false); } } }
/// <summary> /// 更新水平角度移动 /// </summary> private void UpdateHorizontalAngle() { if (TouchConst.TouchIng()) { return; } float axis = 0f; #if UNITY_EDITOR if (Input.GetMouseButton(1)) { axis = Input.GetAxis("Mouse X"); } #elif UNITY_IPHONE || UNITY_ANDROID || UNITY_WP8 || UNITY_WP_8_1 || UNITY_BLACKBERRY if (Input.touchCount > 1 && Input.GetTouch(1).phase == TouchPhase.Moved) { Vector2 delta = Input.GetTouch(0).deltaPosition; axis = delta.x; } #endif mHorizontalAngle += axis * mRotateFactor; }