修复bug

This commit is contained in:
shenjianxing 2025-04-18 15:03:20 +08:00
parent fe1f8fa83b
commit c8642b1afb
4 changed files with 57 additions and 7 deletions

View File

@ -53,7 +53,7 @@ public class Body3DObjItem : MonoBehaviour
} }
private void OnEnter(TuringPointer arg0, GameObject arg1) private void OnEnter(TuringPointer arg0, GameObject arg1)
{ {
if (arg1 == gameObject) if (arg1 == gameObject)
{ {
isEnter = true; isEnter = true;

View File

@ -456,9 +456,6 @@ public class Show3DCamera : MonoBehaviour
// 相机始终朝向目标点 // 相机始终朝向目标点
transform.LookAt(targetPos); transform.LookAt(targetPos);
} }
#if Turing
TypeEventSystem.Global.Send<OnUpdatePos>(new OnUpdatePos() { pos = gameObject.Position(), rot = gameObject.LocalEulerAngles() });
#endif
} }
} }

View File

@ -10,7 +10,7 @@ using DG.Tweening;
public class TuringDraggableEx : Draggable, IObjDrag public class TuringDraggableEx : Draggable, IObjDrag
{ {
bool isOn = false; bool isOn = false;
UnityEvent<GameObject> OnDragEnd; UnityEvent<GameObject> OnDragEnd;
bool IObjDrag.isOn { get => isOn; set => isOn = value; } bool IObjDrag.isOn { get => isOn; set => isOn = value; }
Vector3 beginPos; Vector3 beginPos;
@ -28,13 +28,19 @@ public class TuringDraggableEx : Draggable, IObjDrag
Vector3 startPosition; Vector3 startPosition;
Vector3 startRotation;
private void Start() private void Start()
{ {
isOn = false; isOn = false;
startPosition = gameObject.transform.position; startPosition = gameObject.transform.localPosition;
startRotation = gameObject.transform.localEulerAngles;
} }
public override void OnBeginDrag(PointerEventData eventData) public override void OnBeginDrag(PointerEventData eventData)
{ {
if (eventData.button != 0)
{
return;
}
beginPos = gameObject.Position(); beginPos = gameObject.Position();
if (isOn == false) if (isOn == false)
{ {
@ -51,6 +57,10 @@ public class TuringDraggableEx : Draggable, IObjDrag
public override void OnDrag(PointerEventData eventData) public override void OnDrag(PointerEventData eventData)
{ {
if (eventData.button != 0)
{
return;
}
if (isOn) if (isOn)
{ {
base.OnDrag(eventData); base.OnDrag(eventData);
@ -63,6 +73,10 @@ public class TuringDraggableEx : Draggable, IObjDrag
public override void OnEndDrag(PointerEventData eventData) public override void OnEndDrag(PointerEventData eventData)
{ {
if (eventData.button != 0)
{
return;
}
if (isOn) if (isOn)
{ {
base.OnEndDrag(eventData); base.OnEndDrag(eventData);
@ -73,7 +87,8 @@ public class TuringDraggableEx : Draggable, IObjDrag
public void OnDoubleClick() public void OnDoubleClick()
{ {
transform.DOMove(startPosition, 0.1f); transform.DOLocalMove(startPosition, 0.1f);
transform.localEulerAngles = startRotation;
} }

View File

@ -7,6 +7,7 @@ using UnityEngine.UI;
using XMLTool; using XMLTool;
using System; using System;
using static XMLTool.Body3D; using static XMLTool.Body3D;
using Turing.Core.TuringInput;
namespace QFramework.Example namespace QFramework.Example
{ {
@ -356,8 +357,30 @@ namespace QFramework.Example
TypeEventSystem.Global.Register<OnModuleQuit>((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject); TypeEventSystem.Global.Register<OnModuleQuit>((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject);
#if Turing
UIRoot.Instance.transform.Find("ZStylus").GetComponent<TuringStylus>().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() 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() protected override void OnHide()
{ {
} }