void Update() { Vector3 right = camera.transform.right; Vector3 forward = camera.transform.forward; Vector3 up = camera.transform.up; //Vector3 position = transform.position; //Debug.DrawLine(position - right * 10f, position + right * 10f); //Debug.DrawLine(position - forward * 10f, position + forward * 10f); //Debug.DrawLine(position - up * 10f, position + up * 10f); if (TouchUtility.Enabled && TouchUtility.TouchCount > 0) { Touch touch = TouchUtility.GetTouch(0); if (touch.phase == TouchPhase.Moved) { Vector2 delta = touch.deltaPosition; Vector2 deltaNormalized = delta.normalized; float deltaLength = delta.magnitude; Vector3 direction = right * deltaNormalized.x + up * deltaNormalized.y; Vector3 axis = Vector3.Cross(direction, forward); transform.Rotate(axis, deltaLength * magnitude, Space.World); } } }
private void UpdateVirtualInput() { if (EventSystem.current.IsPointerOverGameObject() || EventSystem.current.IsPointerOverGameObject(0)) { return; } switch (TouchUtility.GetTouch()) { case TouchInfo.Began: //タッチ初めにスクリーン上の位置を記憶 touchStartPos = TouchUtility.GetTouchPosition(); touchingScreen = true; uiManager.SetActiveVirtualPad(true); uiManager.UpdateMovavbleAreaImage(touchStartPos); break; case TouchInfo.Moved: //タッチ中にスクリーン上の位置を記憶① touchCurrentPos = TouchUtility.GetTouchPosition(); uiManager.UpdateCurrentTouchPosImage(touchCurrentPos); break; case TouchInfo.Stationary: //タッチ中にスクリーン上の位置を記憶② touchCurrentPos = TouchUtility.GetTouchPosition(); uiManager.UpdateCurrentTouchPosImage(touchCurrentPos); break; case TouchInfo.Ended: //タッチ終了後にタッチ位置をリセット touchStartPos = Vector2.zero; touchCurrentPos = Vector2.zero; touchingScreen = false; uiManager.SetActiveVirtualPad(false); break; } }
private void Update() { var touch = TouchUtility.GetTouch(0); switch (touch) { case TouchInfo.Began: GenerateBlock("TEST"); break; } }
public override void Update() { if (TouchUtility.Enabled && TouchUtility.TouchCount > 0) { Touch touch = TouchUtility.GetTouch(0); if (touch.phase == TouchPhase.Began && !TouchUtility.TouchedUI(touch.fingerId)) { painter.Paint(); } } targetTransform.Rotate(new Vector3(80f * Time.deltaTime, 0f, 0f)); }
void Update() { if (TouchUtility.Enabled && TouchUtility.TouchCount > 0) { Touch touch = TouchUtility.GetTouch(0); if (touch.phase == TouchPhase.Began) { if (TouchUtility.TouchedUI(touch.fingerId)) { touched = false; return; } Vector2 currentTouchPoint = mainCamera.ScreenToWorldPoint(new Vector3(touch.position.x, touch.position.y, -mainCameraZPos)); if ((currentTouchPoint.ToVector3() - transform.position).sqrMagnitude < dragRadius * dragRadius) { touched = true; previousTouchPoint = currentTouchPoint; } else { touched = false; } } if (touched == true && (touch.phase == TouchPhase.Moved || touch.phase == TouchPhase.Ended)) { Vector2 currentTouchPoint = mainCamera.ScreenToWorldPoint(new Vector3(touch.position.x, touch.position.y, -mainCameraZPos)); Vector2 delta = (currentTouchPoint - previousTouchPoint).LimitLength(maxDragSpeed); if (delta.sqrMagnitude > 0f) { Vector3 chiselPosition = transform.localPosition + delta.ToVector3(); if (chiselPosition.y > clampPositionY) { chiselPosition.y = clampPositionY; } transform.localPosition = chiselPosition; previousTouchPoint = currentTouchPoint; } if (touch.phase == TouchPhase.Ended) { touched = false; } } } }
private void UpdateBoostInAir() { if (isParalyzed) { if (boostParticle.isEmitting) { SetBoostParticleActive(false); } return; } if ((TouchUtility.GetTouch() == TouchInfo.Moved || TouchUtility.GetTouch() == TouchInfo.Stationary) && currentBoostRemain > 0) { currentBoostRemain -= boostCost * Time.deltaTime; if (currentBoostRemain < 0) { currentBoostRemain = 0; } if (isBurst) { currentBoostRemain = boostMax; } else { var l = Mathf.InverseLerp(0, boostMax, currentBoostRemain); var main = boostParticle.main; var c = main.startColor.color; c.r = Mathf.Lerp(boostOverHeatColor.r, boostNormalColor.r, l); c.g = Mathf.Lerp(boostOverHeatColor.g, boostNormalColor.g, l); c.b = Mathf.Lerp(boostOverHeatColor.b, boostNormalColor.b, l); c.a = Mathf.Lerp(boostOverHeatColor.a, boostNormalColor.a, l); main.startColor = c; boostGaugeFill.color = c; } if (!boostParticle.isEmitting) { SetBoostParticleActive(true); } } else if (boostParticle.isEmitting) { SetBoostParticleActive(false); } }
/// <summary> /// タッチポジションを取得(エディタと実機を考慮) /// </summary> /// <returns>タッチポジション。タッチされていない場合は (0, 0, 0)</returns> public static Vector3 GetTouchPosition(int fingerId = 0) { if (Input.touchCount > 0) { Touch touch = Input.GetTouch(fingerId); TouchPosition.x = touch.position.x; TouchPosition.y = touch.position.y; return(TouchPosition); } else { TouchInfo touch = TouchUtility.GetTouch(); if (touch != TouchInfo.None) { return(Input.mousePosition); } } return(Vector3.zero); }
void UpdateTouch() { if (TouchUtility.TouchCount > 0) { Touch touch = TouchUtility.GetTouch(0); Vector2 touchPosition = touch.position; touchPhase = touch.phase; if (touch.phase == TouchPhase.Began) { Vector2 XOYPlaneLocation = mainCamera.ScreenToWorldPoint(new Vector3(touchPosition.x, touchPosition.y, -cameraZPos)); currentTouchPoint = XOYPlaneLocation - terrain.GetPositionOffset(); BuildVertices(currentTouchPoint); terrain.ExecuteClip(this); previousTouchPoint = currentTouchPoint; } else if (touch.phase == TouchPhase.Moved) { Vector2 XOYPlaneLocation = mainCamera.ScreenToWorldPoint(new Vector3(touchPosition.x, touchPosition.y, -cameraZPos)); currentTouchPoint = XOYPlaneLocation - terrain.GetPositionOffset(); if ((currentTouchPoint - previousTouchPoint).sqrMagnitude <= touchMoveDistance * touchMoveDistance) { return; } BuildVertices(previousTouchPoint, currentTouchPoint); terrain.ExecuteClip(this); previousTouchPoint = currentTouchPoint; } } }
private void UpdateBoost() { if (isParalyzed) { return; } isBoosted = (TouchUtility.GetTouch() == TouchInfo.Moved || TouchUtility.GetTouch() == TouchInfo.Stationary); if (currentBoostRemain <= 0) { isBoosted = false; } if (isBoosted != isBoostedOld) { isBoostedOld = isBoosted; if (!SystemManager.GetIsGrounded()) { RB.useGravity = !isBoosted; } } }