Merge branch '3DBody' into 3DBodyVR
This commit is contained in:
commit
3cf08e2ba3
@ -5102,7 +5102,7 @@ MonoBehaviour:
|
|||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
MarkType: 0
|
MarkType: 0
|
||||||
CustomComponentName:
|
CustomComponentName: TitleName
|
||||||
CustomComment:
|
CustomComment:
|
||||||
mComponentName: TMPro.TextMeshProUGUI
|
mComponentName: TMPro.TextMeshProUGUI
|
||||||
--- !u!1 &3757304191228791456
|
--- !u!1 &3757304191228791456
|
||||||
@ -9077,7 +9077,7 @@ RectTransform:
|
|||||||
m_AnchorMin: {x: 0, y: 1}
|
m_AnchorMin: {x: 0, y: 1}
|
||||||
m_AnchorMax: {x: 0, y: 1}
|
m_AnchorMax: {x: 0, y: 1}
|
||||||
m_AnchoredPosition: {x: 30, y: -30}
|
m_AnchoredPosition: {x: 30, y: -30}
|
||||||
m_SizeDelta: {x: 225, y: 0}
|
m_SizeDelta: {x: 0, y: 54}
|
||||||
m_Pivot: {x: 0.000000026077032, y: 1}
|
m_Pivot: {x: 0.000000026077032, y: 1}
|
||||||
--- !u!222 &7766581516026923184
|
--- !u!222 &7766581516026923184
|
||||||
CanvasRenderer:
|
CanvasRenderer:
|
||||||
@ -9191,7 +9191,7 @@ MonoBehaviour:
|
|||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
m_Padding:
|
m_Padding:
|
||||||
m_Left: 0
|
m_Left: 0
|
||||||
m_Right: 0
|
m_Right: 20
|
||||||
m_Top: 0
|
m_Top: 0
|
||||||
m_Bottom: 0
|
m_Bottom: 0
|
||||||
m_ChildAlignment: 3
|
m_ChildAlignment: 3
|
||||||
@ -9215,8 +9215,8 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
|
m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
m_HorizontalFit: 0
|
m_HorizontalFit: 2
|
||||||
m_VerticalFit: 2
|
m_VerticalFit: 0
|
||||||
--- !u!114 &4911184181535695060
|
--- !u!114 &4911184181535695060
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@ -123,108 +123,6 @@ NavMeshSettings:
|
|||||||
debug:
|
debug:
|
||||||
m_Flags: 0
|
m_Flags: 0
|
||||||
m_NavMeshData: {fileID: 0}
|
m_NavMeshData: {fileID: 0}
|
||||||
--- !u!1001 &513830674
|
|
||||||
PrefabInstance:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Modification:
|
|
||||||
serializedVersion: 3
|
|
||||||
m_TransformParent: {fileID: 1269024859}
|
|
||||||
m_Modifications:
|
|
||||||
- target: {fileID: 1462941856791656077, guid: 36d96953b023420408466d801b10c7b7, type: 3}
|
|
||||||
propertyPath: m_Pivot.x
|
|
||||||
value: 0.5
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 1462941856791656077, guid: 36d96953b023420408466d801b10c7b7, type: 3}
|
|
||||||
propertyPath: m_Pivot.y
|
|
||||||
value: 0.5
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 1462941856791656077, guid: 36d96953b023420408466d801b10c7b7, type: 3}
|
|
||||||
propertyPath: m_AnchorMax.x
|
|
||||||
value: 1
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 1462941856791656077, guid: 36d96953b023420408466d801b10c7b7, type: 3}
|
|
||||||
propertyPath: m_AnchorMax.y
|
|
||||||
value: 1
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 1462941856791656077, guid: 36d96953b023420408466d801b10c7b7, type: 3}
|
|
||||||
propertyPath: m_AnchorMin.x
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 1462941856791656077, guid: 36d96953b023420408466d801b10c7b7, type: 3}
|
|
||||||
propertyPath: m_AnchorMin.y
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 1462941856791656077, guid: 36d96953b023420408466d801b10c7b7, type: 3}
|
|
||||||
propertyPath: m_SizeDelta.x
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 1462941856791656077, guid: 36d96953b023420408466d801b10c7b7, type: 3}
|
|
||||||
propertyPath: m_SizeDelta.y
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 1462941856791656077, guid: 36d96953b023420408466d801b10c7b7, type: 3}
|
|
||||||
propertyPath: m_LocalPosition.x
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 1462941856791656077, guid: 36d96953b023420408466d801b10c7b7, type: 3}
|
|
||||||
propertyPath: m_LocalPosition.y
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 1462941856791656077, guid: 36d96953b023420408466d801b10c7b7, type: 3}
|
|
||||||
propertyPath: m_LocalPosition.z
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 1462941856791656077, guid: 36d96953b023420408466d801b10c7b7, type: 3}
|
|
||||||
propertyPath: m_LocalRotation.w
|
|
||||||
value: 1
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 1462941856791656077, guid: 36d96953b023420408466d801b10c7b7, type: 3}
|
|
||||||
propertyPath: m_LocalRotation.x
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 1462941856791656077, guid: 36d96953b023420408466d801b10c7b7, type: 3}
|
|
||||||
propertyPath: m_LocalRotation.y
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 1462941856791656077, guid: 36d96953b023420408466d801b10c7b7, type: 3}
|
|
||||||
propertyPath: m_LocalRotation.z
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 1462941856791656077, guid: 36d96953b023420408466d801b10c7b7, type: 3}
|
|
||||||
propertyPath: m_AnchoredPosition.x
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 1462941856791656077, guid: 36d96953b023420408466d801b10c7b7, type: 3}
|
|
||||||
propertyPath: m_AnchoredPosition.y
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 1462941856791656077, guid: 36d96953b023420408466d801b10c7b7, type: 3}
|
|
||||||
propertyPath: m_LocalEulerAnglesHint.x
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 1462941856791656077, guid: 36d96953b023420408466d801b10c7b7, type: 3}
|
|
||||||
propertyPath: m_LocalEulerAnglesHint.y
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 1462941856791656077, guid: 36d96953b023420408466d801b10c7b7, type: 3}
|
|
||||||
propertyPath: m_LocalEulerAnglesHint.z
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 2554052722243120825, guid: 36d96953b023420408466d801b10c7b7, type: 3}
|
|
||||||
propertyPath: m_Name
|
|
||||||
value: UILoading
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
m_RemovedComponents: []
|
|
||||||
m_RemovedGameObjects: []
|
|
||||||
m_AddedGameObjects: []
|
|
||||||
m_AddedComponents: []
|
|
||||||
m_SourcePrefab: {fileID: 100100000, guid: 36d96953b023420408466d801b10c7b7, type: 3}
|
|
||||||
--- !u!224 &513830675 stripped
|
|
||||||
RectTransform:
|
|
||||||
m_CorrespondingSourceObject: {fileID: 1462941856791656077, guid: 36d96953b023420408466d801b10c7b7, type: 3}
|
|
||||||
m_PrefabInstance: {fileID: 513830674}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
--- !u!1 &547432235
|
--- !u!1 &547432235
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -891,108 +789,6 @@ MonoBehaviour:
|
|||||||
- {fileID: 21300000, guid: 9a698dc39d2b4f843b2a75867e181acb, type: 3}
|
- {fileID: 21300000, guid: 9a698dc39d2b4f843b2a75867e181acb, type: 3}
|
||||||
- {fileID: 21300000, guid: 39d627f6b66e2d34fb070358f8a0a1c5, type: 3}
|
- {fileID: 21300000, guid: 39d627f6b66e2d34fb070358f8a0a1c5, type: 3}
|
||||||
bg: {fileID: 1271049686}
|
bg: {fileID: 1271049686}
|
||||||
--- !u!1 &1269024855
|
|
||||||
GameObject:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
serializedVersion: 6
|
|
||||||
m_Component:
|
|
||||||
- component: {fileID: 1269024859}
|
|
||||||
- component: {fileID: 1269024858}
|
|
||||||
- component: {fileID: 1269024857}
|
|
||||||
- component: {fileID: 1269024856}
|
|
||||||
m_Layer: 5
|
|
||||||
m_Name: Canvas
|
|
||||||
m_TagString: Untagged
|
|
||||||
m_Icon: {fileID: 0}
|
|
||||||
m_NavMeshLayer: 0
|
|
||||||
m_StaticEditorFlags: 0
|
|
||||||
m_IsActive: 1
|
|
||||||
--- !u!114 &1269024856
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 1269024855}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
m_IgnoreReversedGraphics: 1
|
|
||||||
m_BlockingObjects: 0
|
|
||||||
m_BlockingMask:
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Bits: 4294967295
|
|
||||||
--- !u!114 &1269024857
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 1269024855}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
m_UiScaleMode: 0
|
|
||||||
m_ReferencePixelsPerUnit: 100
|
|
||||||
m_ScaleFactor: 1
|
|
||||||
m_ReferenceResolution: {x: 800, y: 600}
|
|
||||||
m_ScreenMatchMode: 0
|
|
||||||
m_MatchWidthOrHeight: 0
|
|
||||||
m_PhysicalUnit: 3
|
|
||||||
m_FallbackScreenDPI: 96
|
|
||||||
m_DefaultSpriteDPI: 96
|
|
||||||
m_DynamicPixelsPerUnit: 1
|
|
||||||
m_PresetInfoIsWorld: 0
|
|
||||||
--- !u!223 &1269024858
|
|
||||||
Canvas:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 1269024855}
|
|
||||||
m_Enabled: 1
|
|
||||||
serializedVersion: 3
|
|
||||||
m_RenderMode: 0
|
|
||||||
m_Camera: {fileID: 0}
|
|
||||||
m_PlaneDistance: 100
|
|
||||||
m_PixelPerfect: 0
|
|
||||||
m_ReceivesEvents: 1
|
|
||||||
m_OverrideSorting: 0
|
|
||||||
m_OverridePixelPerfect: 0
|
|
||||||
m_SortingBucketNormalizedSize: 0
|
|
||||||
m_VertexColorAlwaysGammaSpace: 0
|
|
||||||
m_AdditionalShaderChannelsFlag: 25
|
|
||||||
m_UpdateRectTransformForStandalone: 0
|
|
||||||
m_SortingLayerID: 0
|
|
||||||
m_SortingOrder: 0
|
|
||||||
m_TargetDisplay: 0
|
|
||||||
--- !u!224 &1269024859
|
|
||||||
RectTransform:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 1269024855}
|
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
|
||||||
m_LocalScale: {x: 0, y: 0, z: 0}
|
|
||||||
m_ConstrainProportionsScale: 0
|
|
||||||
m_Children:
|
|
||||||
- {fileID: 513830675}
|
|
||||||
m_Father: {fileID: 0}
|
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
|
||||||
m_AnchorMin: {x: 0, y: 0}
|
|
||||||
m_AnchorMax: {x: 0, y: 0}
|
|
||||||
m_AnchoredPosition: {x: 0, y: 0}
|
|
||||||
m_SizeDelta: {x: 0, y: 0}
|
|
||||||
m_Pivot: {x: 0, y: 0}
|
|
||||||
--- !u!1 &1271049684
|
--- !u!1 &1271049684
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -1533,7 +1329,7 @@ MonoBehaviour:
|
|||||||
rotateSpeed: 10
|
rotateSpeed: 10
|
||||||
moveSpeed: 0.1
|
moveSpeed: 0.1
|
||||||
distance: 2
|
distance: 2
|
||||||
distanceMin: 1
|
distanceMin: 0.5
|
||||||
distanceMax: 15
|
distanceMax: 15
|
||||||
pitchMinMax: {x: -80, y: 80}
|
pitchMinMax: {x: -80, y: 80}
|
||||||
texture: {fileID: 8400000, guid: 187fba8368491cb428c8cbd324fa9bb4, type: 2}
|
texture: {fileID: 8400000, guid: 187fba8368491cb428c8cbd324fa9bb4, type: 2}
|
||||||
@ -1547,7 +1343,6 @@ SceneRoots:
|
|||||||
- {fileID: 1655025501}
|
- {fileID: 1655025501}
|
||||||
- {fileID: 547432243}
|
- {fileID: 547432243}
|
||||||
- {fileID: 1089184134}
|
- {fileID: 1089184134}
|
||||||
- {fileID: 1269024859}
|
|
||||||
- {fileID: 2114935606}
|
- {fileID: 2114935606}
|
||||||
- {fileID: 555070719}
|
- {fileID: 555070719}
|
||||||
- {fileID: 2028686194}
|
- {fileID: 2028686194}
|
||||||
|
|||||||
@ -15,3 +15,7 @@ struct EndScreenShot
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct OnLock
|
||||||
|
{
|
||||||
|
public bool isLock;
|
||||||
|
}
|
||||||
@ -1,3 +1,4 @@
|
|||||||
|
using QFramework;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -11,8 +12,23 @@ public class ObjectToggle : MonoBehaviour
|
|||||||
public UnityEvent<bool> OnValueChanged = new UnityEvent<bool>();
|
public UnityEvent<bool> OnValueChanged = new UnityEvent<bool>();
|
||||||
private float mouseDownTime;
|
private float mouseDownTime;
|
||||||
private bool isMouseDown;
|
private bool isMouseDown;
|
||||||
|
bool isLock = false;
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
TypeEventSystem.Global.Register<OnLock>(OnLockEvent).UnRegisterWhenDisabled(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnLockEvent(OnLock islock)
|
||||||
|
{
|
||||||
|
this.isLock = islock.isLock;
|
||||||
|
}
|
||||||
|
|
||||||
private void OnMouseDown()
|
private void OnMouseDown()
|
||||||
{
|
{
|
||||||
|
if (isLock == true)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
// 记录鼠标按下的时间
|
// 记录鼠标按下的时间
|
||||||
mouseDownTime = Time.time;
|
mouseDownTime = Time.time;
|
||||||
isMouseDown = true;
|
isMouseDown = true;
|
||||||
@ -44,4 +60,5 @@ public class ObjectToggle : MonoBehaviour
|
|||||||
this.isOn = isOn;
|
this.isOn = isOn;
|
||||||
OnValueChanged?.Invoke(isOn);
|
OnValueChanged?.Invoke(isOn);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
using DG.Tweening;
|
using DG.Tweening;
|
||||||
|
using QFramework;
|
||||||
|
using System;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
|
|
||||||
@ -41,14 +43,20 @@ public class Show3DCamera : MonoBehaviour
|
|||||||
Transform target;
|
Transform target;
|
||||||
Vector3 targetPosition;
|
Vector3 targetPosition;
|
||||||
Vector3 targetRotate;
|
Vector3 targetRotate;
|
||||||
|
private float prevTouchDistance; // 存储上一帧双指距离
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
instance = this;
|
instance = this;
|
||||||
self = transform.GetComponent<Camera>();
|
self = transform.GetComponent<Camera>();
|
||||||
DontDestroyOnLoad(this);
|
DontDestroyOnLoad(this);
|
||||||
gameObject.SetActive(false);
|
gameObject.SetActive(false);
|
||||||
|
TypeEventSystem.Global.Register<OnLock>(OnLockEvent).UnRegisterWhenDisabled(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnLockEvent(OnLock islock)
|
||||||
|
{
|
||||||
|
this.lockMove = islock.isLock;
|
||||||
|
}
|
||||||
|
|
||||||
public void Set(Transform target, float rotateSpeed = 10, float moveSpeed = 0.1f, float distance = 0.1f, float pitchMin = -20, float pitchMax = 80, float distanceMin = 0.2f, float distanceMax = 20f, RectTransform inputRect = null, bool isRenderTexture = true, float moveTime = -1)
|
public void Set(Transform target, float rotateSpeed = 10, float moveSpeed = 0.1f, float distance = 0.1f, float pitchMin = -20, float pitchMax = 80, float distanceMin = 0.2f, float distanceMax = 20f, RectTransform inputRect = null, bool isRenderTexture = true, float moveTime = -1)
|
||||||
{
|
{
|
||||||
@ -117,27 +125,42 @@ public class Show3DCamera : MonoBehaviour
|
|||||||
UpdateCameraPosition(-1);
|
UpdateCameraPosition(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
if (targetPos != null && lockMove == false && EventSystem.current.IsPointerOverGameObject() == false)
|
if (targetPos != null && lockMove == false && EventSystem.current.IsPointerOverGameObject() == false)
|
||||||
{
|
{
|
||||||
|
// 优先处理三指操作
|
||||||
|
if (HandleThreeFingerDrag()) return;
|
||||||
|
bool isTouching = Input.touchCount > 0;
|
||||||
|
|
||||||
|
// 新增:在旋转前先处理双指缩放
|
||||||
if (Input.GetMouseButtonDown(0))
|
bool isZooming = false;
|
||||||
|
if (isTouching && Input.touchCount == 2)
|
||||||
|
{
|
||||||
|
HandleTouchZoom();
|
||||||
|
isZooming = true; // 标记正在缩放
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理触摸开始(排除双指情况)
|
||||||
|
if (isTouching && Input.touchCount == 1)
|
||||||
|
{
|
||||||
|
if (Input.GetTouch(0).phase == TouchPhase.Began)
|
||||||
|
{
|
||||||
|
mouseDownPosition = Input.GetTouch(0).position;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 处理鼠标按下
|
||||||
|
else if (Input.GetMouseButtonDown(0))
|
||||||
{
|
{
|
||||||
// 记录鼠标按下时的位置
|
|
||||||
mouseDownPosition = Input.mousePosition;
|
mouseDownPosition = Input.mousePosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 按住鼠标左键时旋转相机
|
// 修改后的旋转条件(排除缩放状态)
|
||||||
if (Input.GetMouseButton(0))
|
if (!isZooming && (isTouching ? (Input.GetTouch(0).phase == TouchPhase.Moved) : Input.GetMouseButton(0)))
|
||||||
{
|
{
|
||||||
// 计算鼠标按下和抬起位置之间的距离
|
// 移除距离判断直接响应
|
||||||
float distance = Vector2.Distance(mouseDownPosition, Input.mousePosition);
|
RotateCamera();
|
||||||
if (distance > 1f)
|
|
||||||
{
|
|
||||||
RotateCamera();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 鼠标滚轮缩放
|
// 鼠标滚轮缩放
|
||||||
@ -147,7 +170,6 @@ public class Show3DCamera : MonoBehaviour
|
|||||||
ZoomCamera(scroll);
|
ZoomCamera(scroll);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 按住鼠标右键时移动目标点
|
// 按住鼠标右键时移动目标点
|
||||||
if (Input.GetMouseButton(1))
|
if (Input.GetMouseButton(1))
|
||||||
{
|
{
|
||||||
@ -156,6 +178,91 @@ public class Show3DCamera : MonoBehaviour
|
|||||||
DetectHoveredObject();
|
DetectHoveredObject();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 唯一的三指处理方法(返回bool用于阻断其他操作)
|
||||||
|
private bool HandleThreeFingerDrag()
|
||||||
|
{
|
||||||
|
if (Input.touchCount == 5)
|
||||||
|
{
|
||||||
|
// 计算三个触点的平均移动量
|
||||||
|
Vector2 totalDelta = Vector2.zero;
|
||||||
|
foreach (Touch t in Input.touches)
|
||||||
|
{
|
||||||
|
totalDelta += t.deltaPosition;
|
||||||
|
}
|
||||||
|
Vector2 delta = totalDelta / 3f;
|
||||||
|
|
||||||
|
// DPI自适应处理
|
||||||
|
float dpiScale = Screen.dpi == 0 ? 1 : Screen.dpi / 160f;
|
||||||
|
float sensitivity = moveSpeed * 0.1f / dpiScale;
|
||||||
|
|
||||||
|
// 应用移动阈值(2像素)
|
||||||
|
if (delta.magnitude > 2f)
|
||||||
|
{
|
||||||
|
// 调用修改后的移动方法
|
||||||
|
MoveTarget(delta.x * sensitivity, delta.y * sensitivity);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 阻断其他触摸操作
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 新增双指缩放处理方法
|
||||||
|
// 类变量区添加
|
||||||
|
private float zoomSmoothVelocity; // 平滑速度缓存
|
||||||
|
[SerializeField] private float zoomSmoothTime = 0.1f; // 缩放平滑时间
|
||||||
|
private void HandleTouchZoom()
|
||||||
|
{
|
||||||
|
if (Input.touchCount == 2)
|
||||||
|
{
|
||||||
|
Touch touch0 = Input.GetTouch(0);
|
||||||
|
Touch touch1 = Input.GetTouch(1);
|
||||||
|
// 当双指操作时重置旋转相关变量
|
||||||
|
if (touch0.phase == TouchPhase.Began || touch1.phase == TouchPhase.Began)
|
||||||
|
{
|
||||||
|
yaw = transform.eulerAngles.y; // 保持当前旋转角度
|
||||||
|
pitch = transform.eulerAngles.x;
|
||||||
|
mouseDownPosition = Vector2.zero;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector2 touch0Pos = touch0.position;
|
||||||
|
Vector2 touch1Pos = touch1.position;
|
||||||
|
float currentDistance = Vector2.Distance(touch0Pos, touch1Pos);
|
||||||
|
|
||||||
|
// DPI自适应计算
|
||||||
|
float dpi = Screen.dpi == 0 ? 200 : Screen.dpi;
|
||||||
|
float zoomFactor = 0.01f * (200 / dpi); // 基准DPI为200
|
||||||
|
|
||||||
|
if (touch0.phase == TouchPhase.Began || touch1.phase == TouchPhase.Began)
|
||||||
|
{
|
||||||
|
prevTouchDistance = currentDistance;
|
||||||
|
zoomSmoothVelocity = 0; // 重置平滑速度
|
||||||
|
}
|
||||||
|
else if (touch0.phase == TouchPhase.Moved || touch1.phase == TouchPhase.Moved)
|
||||||
|
{
|
||||||
|
float deltaDistance = currentDistance - prevTouchDistance;
|
||||||
|
|
||||||
|
// 仅触摸缩放使用平滑
|
||||||
|
float targetDistance = distance - deltaDistance * zoomFactor;
|
||||||
|
targetDistance = Mathf.Clamp(targetDistance, distanceMin, distanceMax);
|
||||||
|
|
||||||
|
distance = Mathf.SmoothDamp(
|
||||||
|
distance,
|
||||||
|
targetDistance,
|
||||||
|
ref zoomSmoothVelocity,
|
||||||
|
zoomSmoothTime
|
||||||
|
);
|
||||||
|
|
||||||
|
offset = new Vector3(0, 0, -distance);
|
||||||
|
UpdateCameraPosition();
|
||||||
|
|
||||||
|
prevTouchDistance = currentDistance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 检测鼠标悬停的物体
|
// 检测鼠标悬停的物体
|
||||||
public void DetectHoveredObject()
|
public void DetectHoveredObject()
|
||||||
@ -245,11 +352,15 @@ public class Show3DCamera : MonoBehaviour
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 移动目标点
|
// 修改后的移动方法(统一处理输入源)
|
||||||
private void MoveTarget()
|
private void MoveTarget(float mouseX = 0, float mouseY = 0)
|
||||||
{
|
{
|
||||||
float mouseX = Input.GetAxis("Mouse X") * moveSpeed;
|
// 自动判断输入源
|
||||||
float mouseY = Input.GetAxis("Mouse Y") * moveSpeed;
|
if (Mathf.Approximately(mouseX, 0) && Mathf.Approximately(mouseY, 0))
|
||||||
|
{
|
||||||
|
mouseX = Input.GetAxis("Mouse X") * moveSpeed;
|
||||||
|
mouseY = Input.GetAxis("Mouse Y") * moveSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
transform.Translate(new Vector3(-mouseX, -mouseY, 0));
|
transform.Translate(new Vector3(-mouseX, -mouseY, 0));
|
||||||
targetPos += new Vector3(-mouseX, -mouseY, 0);
|
targetPos += new Vector3(-mouseX, -mouseY, 0);
|
||||||
@ -263,31 +374,44 @@ public class Show3DCamera : MonoBehaviour
|
|||||||
UpdateCameraPosition();
|
UpdateCameraPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 旋转相机
|
// 修改RotateCamera方法
|
||||||
private void RotateCamera()
|
private void RotateCamera()
|
||||||
{
|
{
|
||||||
// 获取鼠标移动量
|
// 优先使用触摸输入
|
||||||
float mouseX = Input.GetAxis("Mouse X") * rotateSpeed;
|
float deltaX = 0, deltaY = 0;
|
||||||
float mouseY = Input.GetAxis("Mouse Y") * rotateSpeed;
|
|
||||||
|
// 触屏处理
|
||||||
|
if (Input.touchCount == 1)
|
||||||
|
{
|
||||||
|
Touch touch = Input.GetTouch(0);
|
||||||
|
deltaX = touch.deltaPosition.x;
|
||||||
|
deltaY = touch.deltaPosition.y;
|
||||||
|
}
|
||||||
|
// 鼠标处理
|
||||||
|
else
|
||||||
|
{
|
||||||
|
deltaX = Input.GetAxis("Mouse X") * 10; // 保持原有灵敏度
|
||||||
|
deltaY = Input.GetAxis("Mouse Y") * 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 应用DPI缩放(关键!)
|
||||||
|
float dpiScale = Screen.dpi == 0 ? 1 : Screen.dpi / 160f;
|
||||||
|
deltaX *= rotateSpeed * Time.deltaTime / dpiScale;
|
||||||
|
deltaY *= rotateSpeed * Time.deltaTime / dpiScale;
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case RotationType.Orbit:
|
case RotationType.Orbit:
|
||||||
|
yaw += deltaX;
|
||||||
// 更新偏航角和俯仰角
|
pitch -= deltaY;
|
||||||
yaw += mouseX;
|
pitch = Mathf.Clamp(pitch, pitchMinMax.x, pitchMinMax.y);
|
||||||
pitch -= mouseY; // 注意:鼠标 Y 轴移动方向与俯仰角相反
|
|
||||||
pitch = Mathf.Clamp(pitch, pitchMinMax.x, pitchMinMax.y); // 限制俯仰角范围
|
|
||||||
|
|
||||||
// 更新相机位置
|
|
||||||
UpdateCameraPosition();
|
UpdateCameraPosition();
|
||||||
break;
|
break;
|
||||||
case RotationType.Spherical:
|
case RotationType.Spherical:
|
||||||
// 完全自由的旋转(包含X/Y/Z三个轴向)
|
target.Rotate(Vector3.up, deltaX, Space.World);
|
||||||
target.Rotate(Vector3.up, mouseX, Space.World); // 水平方向世界Y轴旋转
|
target.Rotate(Vector3.right, -deltaY, Space.Self);
|
||||||
target.Rotate(Vector3.right, -mouseY, Space.Self); // 垂直方向本地X轴旋转
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ChangeMode(RotationType type)
|
public void ChangeMode(RotationType type)
|
||||||
|
|||||||
@ -233,7 +233,7 @@ namespace QFramework.Example
|
|||||||
LockMode.transform.Find("Label").GetComponent<TextMeshProUGUI>().text = "Ëø¶¨ÆÁÄ»";
|
LockMode.transform.Find("Label").GetComponent<TextMeshProUGUI>().text = "Ëø¶¨ÆÁÄ»";
|
||||||
LockMode.transform.Find("Label").GetComponent<TextMeshProUGUI>().color = new Color(74f / 255f, 91f / 255f, 116f / 255f);
|
LockMode.transform.Find("Label").GetComponent<TextMeshProUGUI>().color = new Color(74f / 255f, 91f / 255f, 116f / 255f);
|
||||||
}
|
}
|
||||||
Show3DCamera.instance.lockMove = isOn;
|
TypeEventSystem.Global.Send<OnLock>(new OnLock() { isLock = isOn });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
<Module>
|
<Module>
|
||||||
<Scene>Test</Scene>
|
<Scene>Test</Scene>
|
||||||
<Type>All</Type>
|
<Type>All</Type>
|
||||||
<Name>3D解刨</Name>
|
<Name>头面颈部解剖虚拟仿真训练系统</Name>
|
||||||
|
|
||||||
|
|
||||||
<FSM name="状态机1">
|
<FSM name="状态机1">
|
||||||
|
|||||||
@ -37,6 +37,7 @@ GraphicsSettings:
|
|||||||
- {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0}
|
- {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
- {fileID: 16001, guid: 0000000000000000f000000000000000, type: 0}
|
- {fileID: 16001, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
- {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0}
|
- {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
|
- {fileID: 4800000, guid: c8b5bc66eaa9c574cb2bfefd127c88b9, type: 3}
|
||||||
m_PreloadedShaders: []
|
m_PreloadedShaders: []
|
||||||
m_PreloadShadersBatchTimeLimit: -1
|
m_PreloadShadersBatchTimeLimit: -1
|
||||||
m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
|
m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user