//========================================================== // // Copyright (c) Guangzhou Shixiang Technology Co.,Ltd. // All rights reserved. // //========================================================== using System; using GxrSdk; using UnityEngine; public class TouchHandle : GxrDraggableTouchBehavior { /// /// 在这里根据触摸位置来更新transform.position位置信息 /// /// 范围[-1,1] /// 范围[-1,1] protected override void UpdateTransform(Vector2 currentTouchPosition, Vector2 lastTouchPosition) { var deltaPosition = currentTouchPosition - lastTouchPosition; var factorX = deltaPosition.x < 0 ? -1 : 1; var factorY = deltaPosition.y < 0 ? -1 : 1; var dx = Math.Abs(deltaPosition.x); var dy = Math.Abs(deltaPosition.y); if (dx >= dy) { // 左右滑动缩放 } else { // 前后滑动远近 IGxrPointer pointer = GxrPointerManager.Instance.MainPointer; var direct = pointer.Rotation * Vector3.forward; var targetPosition = transform.position + factorY * 0.4f * direct; transform.position = targetPosition; } } }