From c8642b1afb47db895738b183f323635d56f9ba5a Mon Sep 17 00:00:00 2001 From: shenjianxing <”315615051@qq.com“> Date: Fri, 18 Apr 2025 15:03:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Item/Body3DObjItem.cs | 2 +- Assets/Scripts/Item/Show3DCamera.cs | 3 -- Assets/Scripts/TuringVR/TuringDraggableEx.cs | 21 +++++++++-- Assets/Scripts/UI/UIBody3D.cs | 38 ++++++++++++++++++++ 4 files changed, 57 insertions(+), 7 deletions(-) diff --git a/Assets/Scripts/Item/Body3DObjItem.cs b/Assets/Scripts/Item/Body3DObjItem.cs index 738a3d56..0f2118b5 100644 --- a/Assets/Scripts/Item/Body3DObjItem.cs +++ b/Assets/Scripts/Item/Body3DObjItem.cs @@ -53,7 +53,7 @@ public class Body3DObjItem : MonoBehaviour } private void OnEnter(TuringPointer arg0, GameObject arg1) - { + { if (arg1 == gameObject) { isEnter = true; diff --git a/Assets/Scripts/Item/Show3DCamera.cs b/Assets/Scripts/Item/Show3DCamera.cs index d5456f95..a4d7f7d9 100644 --- a/Assets/Scripts/Item/Show3DCamera.cs +++ b/Assets/Scripts/Item/Show3DCamera.cs @@ -456,9 +456,6 @@ public class Show3DCamera : MonoBehaviour // ʼճĿ transform.LookAt(targetPos); } -#if Turing - TypeEventSystem.Global.Send(new OnUpdatePos() { pos = gameObject.Position(), rot = gameObject.LocalEulerAngles() }); -#endif } } diff --git a/Assets/Scripts/TuringVR/TuringDraggableEx.cs b/Assets/Scripts/TuringVR/TuringDraggableEx.cs index 96f34532..3295bd61 100644 --- a/Assets/Scripts/TuringVR/TuringDraggableEx.cs +++ b/Assets/Scripts/TuringVR/TuringDraggableEx.cs @@ -10,7 +10,7 @@ using DG.Tweening; public class TuringDraggableEx : Draggable, IObjDrag { bool isOn = false; - UnityEvent OnDragEnd; + UnityEvent OnDragEnd; bool IObjDrag.isOn { get => isOn; set => isOn = value; } Vector3 beginPos; @@ -28,13 +28,19 @@ public class TuringDraggableEx : Draggable, IObjDrag Vector3 startPosition; + Vector3 startRotation; private void Start() { isOn = false; - startPosition = gameObject.transform.position; + startPosition = gameObject.transform.localPosition; + startRotation = gameObject.transform.localEulerAngles; } public override void OnBeginDrag(PointerEventData eventData) { + if (eventData.button != 0) + { + return; + } beginPos = gameObject.Position(); if (isOn == false) { @@ -51,6 +57,10 @@ public class TuringDraggableEx : Draggable, IObjDrag public override void OnDrag(PointerEventData eventData) { + if (eventData.button != 0) + { + return; + } if (isOn) { base.OnDrag(eventData); @@ -63,6 +73,10 @@ public class TuringDraggableEx : Draggable, IObjDrag public override void OnEndDrag(PointerEventData eventData) { + if (eventData.button != 0) + { + return; + } if (isOn) { base.OnEndDrag(eventData); @@ -73,7 +87,8 @@ public class TuringDraggableEx : Draggable, IObjDrag public void OnDoubleClick() { - transform.DOMove(startPosition, 0.1f); + transform.DOLocalMove(startPosition, 0.1f); + transform.localEulerAngles = startRotation; } diff --git a/Assets/Scripts/UI/UIBody3D.cs b/Assets/Scripts/UI/UIBody3D.cs index 0fd0b1b1..52ee0646 100644 --- a/Assets/Scripts/UI/UIBody3D.cs +++ b/Assets/Scripts/UI/UIBody3D.cs @@ -7,6 +7,7 @@ using UnityEngine.UI; using XMLTool; using System; using static XMLTool.Body3D; +using Turing.Core.TuringInput; namespace QFramework.Example { @@ -356,8 +357,30 @@ namespace QFramework.Example TypeEventSystem.Global.Register((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject); + +#if Turing + + UIRoot.Instance.transform.Find("ZStylus").GetComponent().OnButtonPressing.AddListener(OnButtonPressing); +#endif + + } +#if Turing + private void OnButtonPressing(TuringPointer arg0, int arg1) + { + if (arg1 == 1) + { + // ת壬ʹ Time.deltaTime ȷתٶ֡޹ + root.transform.Rotate(Vector3.up, -100 * Time.deltaTime); + } + else if (arg1 == 2) + { // ת壬ʹ Time.deltaTime ȷתٶ֡޹ + root.transform.Rotate(Vector3.up, 100 * Time.deltaTime); + } + } +#endif + private void OnUIBody3DMenuTreeClose() { @@ -528,6 +551,21 @@ namespace QFramework.Example } } + //private void Update() + //{ + // if (Input.GetKey(KeyCode.A)) + // { + // // ת壬ʹ Time.deltaTime ȷתٶ֡޹ + // root.transform.Rotate(Vector3.up, -100 * Time.deltaTime); + + // } + + // if (Input.GetKey(KeyCode.B)) + // { + // // ת壬ʹ Time.deltaTime ȷתٶ֡޹ + // root.transform.Rotate(Vector3.up, 100 * Time.deltaTime); + // } + //} protected override void OnHide() { }