protected virtual void UpdateAnimations() { if (m_Animator) { m_Animator.SetFloat("Button 1", InputDevices.GetKeyForce(isLeft ? 0 : 1, InputKey.Primary)); m_Animator.SetFloat("Button 2", InputDevices.GetKeyForce(isLeft ? 0 : 1, InputKey.Secondary)); m_Animator.SetFloat("Joy X", InputDevices.GetTouchAxis(isLeft ? 0 : 1).x); m_Animator.SetFloat("Joy Y", InputDevices.GetTouchAxis(isLeft ? 0 : 1).y); m_Animator.SetFloat("Grip", InputDevices.GetKeyForce(isLeft ? 0 : 1, InputKey.Grip)); m_Animator.SetFloat("Trigger", InputDevices.GetKeyForce(isLeft ? 0 : 1, InputKey.Trigger)); } }
protected override void UpdateHitState(ref RaycastResult raycast) { isHit = raycast.gameObject != null; if (isHit) { Vector3 lastHitPoint = hitPoint; //左手按鍵狀態 if (inputType == InputType.LeftHand) { Vector2 aixs = InputDevices.GetTouchAxis(0); if (aixs.sqrMagnitude > scrollThrelod) { scrollDelta = aixs * handScrollSensitivity; } } //右手按鍵狀態 else if (inputType == InputType.RightHand) { Vector2 aixs = InputDevices.GetTouchAxis(1); if (aixs.sqrMagnitude > scrollThrelod) { scrollDelta = aixs * handScrollSensitivity; } } //Unity原生模式狀態 else if (inputType == InputType.Mouse) { #if UNITY_STANDALONE || UNITY_EDITOR scrollDelta = Input.mouseScrollDelta; #elif UNITY_ANDROID || UNITY_IOS if (Input.touchCount > 0) { Touch touch = Input.GetTouch(0); delta = touch.deltaPosition; } #endif } hitPoint = raycast.worldPosition; hitNormal = raycast.worldNormal; hitTarget = raycast.gameObject; Vector3 moveDelta = hitPoint - lastHitPoint; delta = moveDelta - Vector3.Project(moveDelta, hitNormal); } UpdateRenderer(); }