<fix>위치 정보 수정/삭제 완료
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
@@ -15,7 +16,7 @@ public class InteractionView : MonoBehaviour, IInteractionView
|
||||
{
|
||||
public event Action<Vector3, Quaternion> OnRobotGrabbed;
|
||||
public event Action<RobotData> OnRobotReleased;
|
||||
public event Action<int> OnPointClicked;
|
||||
public event Action<int, Vector3> OnPointClicked;
|
||||
public event Action<int> OnPointDragStart;
|
||||
public event Action<int, Vector3, Quaternion> OnPointDragUpdate;
|
||||
public event Action<int> OnPointDragEnd;
|
||||
@@ -30,11 +31,18 @@ public class InteractionView : MonoBehaviour, IInteractionView
|
||||
[SerializeField]
|
||||
[Tooltip("드래그용 마우스 이미지")]
|
||||
private GameObject dragArrow;
|
||||
[SerializeField] private float clickTimeThreshold = 0.5f;
|
||||
[SerializeField] private float dragMovementThreshold = 0.05f;
|
||||
private Coroutine clickOrDragCoroutine = null;
|
||||
private Vector3 startGrabPosition;
|
||||
|
||||
private bool isInitialized = false;
|
||||
private bool isGrabbingPoint = false;
|
||||
private int currentGrabbedPointIndex = -1;
|
||||
|
||||
Vector3 currentTargetPosition = Vector3.zero;
|
||||
Quaternion currentTargetRotation = Quaternion.identity;
|
||||
|
||||
public bool isGrabbingRobot = false;
|
||||
|
||||
void Start()
|
||||
@@ -76,21 +84,29 @@ public class InteractionView : MonoBehaviour, IInteractionView
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector3 currentTargetPosition = Vector3.zero;
|
||||
Quaternion currentTargetRotation = Quaternion.identity;
|
||||
|
||||
currentTargetPosition = rayProvider.rayEndPoint;
|
||||
currentTargetRotation = baseInteractor.attachTransform.rotation;
|
||||
|
||||
if (isGrabbingRobot)
|
||||
{
|
||||
OnRobotGrabbed?.Invoke(currentTargetPosition, currentTargetRotation);
|
||||
return;
|
||||
}
|
||||
|
||||
if (isGrabbingPoint)
|
||||
{
|
||||
OnPointDragUpdate?.Invoke(currentGrabbedPointIndex, currentTargetPosition, currentTargetRotation);
|
||||
}
|
||||
else if (isGrabbingRobot)
|
||||
else if (clickOrDragCoroutine != null)
|
||||
{
|
||||
OnRobotGrabbed?.Invoke(currentTargetPosition, currentTargetRotation);
|
||||
float distance = Vector3.Distance(startGrabPosition, currentTargetPosition);
|
||||
|
||||
if (distance > dragMovementThreshold)
|
||||
{
|
||||
StartDragMode();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,8 +126,6 @@ public class InteractionView : MonoBehaviour, IInteractionView
|
||||
{
|
||||
baseInteractor.selectEntered.RemoveListener(HandleGrabStart);
|
||||
baseInteractor.selectExited.RemoveListener(HandleGrabEnd);
|
||||
//interactor.activated.RemoveListener(OnActivated);
|
||||
//interactor.deactivated.RemoveListener(OnDeactivated);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +142,13 @@ public class InteractionView : MonoBehaviour, IInteractionView
|
||||
isGrabbingRobot = false;
|
||||
currentGrabbedPointIndex = point.pointIndex;
|
||||
|
||||
OnPointDragStart?.Invoke(currentGrabbedPointIndex);
|
||||
// 타이머 시작
|
||||
startGrabPosition = rayProvider.rayEndPoint;
|
||||
if (clickOrDragCoroutine != null)
|
||||
StopCoroutine(clickOrDragCoroutine);
|
||||
clickOrDragCoroutine = StartCoroutine(ClickOrDragTimer());
|
||||
|
||||
//OnPointDragStart?.Invoke(currentGrabbedPointIndex);
|
||||
}
|
||||
else if (grabbedGO.CompareTag("RobotArm"))
|
||||
{
|
||||
@@ -142,21 +162,57 @@ public class InteractionView : MonoBehaviour, IInteractionView
|
||||
|
||||
private void HandleGrabEnd(SelectExitEventArgs args)
|
||||
{
|
||||
if (isGrabbingPoint)
|
||||
{
|
||||
OnPointDragEnd?.Invoke(currentGrabbedPointIndex);
|
||||
}
|
||||
else if (isGrabbingRobot)
|
||||
if (isGrabbingRobot)
|
||||
{
|
||||
OnRobotReleased?.Invoke(new RobotData());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (clickOrDragCoroutine != null)
|
||||
{
|
||||
StopCoroutine(clickOrDragCoroutine);
|
||||
clickOrDragCoroutine = null;
|
||||
|
||||
OnPointClicked?.Invoke(currentGrabbedPointIndex, currentTargetPosition);
|
||||
}
|
||||
else if (isGrabbingPoint)
|
||||
{
|
||||
OnPointDragEnd?.Invoke(currentGrabbedPointIndex);
|
||||
}
|
||||
}
|
||||
|
||||
// 상태 초기화
|
||||
clickOrDragCoroutine = null;
|
||||
isGrabbingPoint = false;
|
||||
isGrabbingRobot = false;
|
||||
currentGrabbedPointIndex = -1;
|
||||
}
|
||||
|
||||
// 클릭/드래그 구분하는 타이머 코루틴
|
||||
private IEnumerator ClickOrDragTimer()
|
||||
{
|
||||
yield return new WaitForSeconds(clickTimeThreshold);
|
||||
|
||||
if (clickOrDragCoroutine != null)
|
||||
{
|
||||
Debug.Log("시간 초과로 드래그 시작 (OnPointDragStart)");
|
||||
StartDragMode();
|
||||
}
|
||||
}
|
||||
|
||||
// 타이머 중지하고 드래그 모드로 전환
|
||||
private void StartDragMode()
|
||||
{
|
||||
if (clickOrDragCoroutine != null)
|
||||
{
|
||||
StopCoroutine(clickOrDragCoroutine);
|
||||
clickOrDragCoroutine = null;
|
||||
}
|
||||
|
||||
isGrabbingPoint = true;
|
||||
OnPointDragStart?.Invoke(currentGrabbedPointIndex);
|
||||
}
|
||||
|
||||
// 로봇 좌표계(mm)를 Unity 월드 좌표계(m)로 변환
|
||||
private Vector3 ConvertRobotDataToVector3(RobotData pose)
|
||||
{
|
||||
|
||||
@@ -17,6 +17,11 @@ public class PointManagerView : MonoBehaviour, IPointManagerView
|
||||
[Tooltip("반투명 로봇 모델의 IK")]
|
||||
public HybridInverseKinematicsNode kinematicsNode;
|
||||
|
||||
void Start()
|
||||
{
|
||||
movingAlert.SetActive(false);
|
||||
}
|
||||
|
||||
private Vector3 ConvertRobotDataToVector3(RobotData pose)
|
||||
{
|
||||
float x = Convert.ToSingle(pose.x / -1000.0); // mm -> m
|
||||
|
||||
@@ -50,27 +50,38 @@ public class PopupView : MonoBehaviour, IPopupView
|
||||
optionPopupPanel.SetActive(false);
|
||||
}
|
||||
|
||||
public void ShowConfirmPopup(Transform popPose)
|
||||
public void ShowConfirmPopupFromRobot(Transform popPose)
|
||||
{
|
||||
confirmPopupPanel.transform.SetPositionAndRotation(popPose.position, Quaternion.identity);
|
||||
confirmPopupPanel.transform.position = popPose.position;
|
||||
confirmPopupPanel.transform.LookAt(Camera.main.transform);
|
||||
confirmPopupPanel.SetActive(true);
|
||||
}
|
||||
|
||||
public void ShowConfirmPopupFromPoint(Vector3 popPose)
|
||||
{
|
||||
confirmPopupPanel.transform.position = popPose;
|
||||
confirmPopupPanel.transform.LookAt(Camera.main.transform);
|
||||
confirmPopupPanel.SetActive(true);
|
||||
}
|
||||
|
||||
public void ShowModifyPopup(Transform popPose)
|
||||
{
|
||||
modifyPopupPanel.transform.SetPositionAndRotation(popPose.position, Quaternion.identity);
|
||||
modifyPopupPanel.transform.position = popPose.position;
|
||||
modifyPopupPanel.transform.LookAt(Camera.main.transform);
|
||||
modifyPopupPanel.SetActive(true);
|
||||
}
|
||||
|
||||
public void ShowDeletePopup(Transform popPose)
|
||||
public void ShowDeletePopup(Vector3 popPose)
|
||||
{
|
||||
deletePopupPanel.transform.SetPositionAndRotation(popPose.position, Quaternion.identity);
|
||||
deletePopupPanel.transform.position = popPose;
|
||||
deletePopupPanel.transform.LookAt(Camera.main.transform);
|
||||
deletePopupPanel.SetActive(true);
|
||||
}
|
||||
|
||||
public void ShowOptionPopup(Transform popPose)
|
||||
public void ShowOptionPopup(Vector3 popPose)
|
||||
{
|
||||
optionPopupPanel.transform.SetPositionAndRotation(popPose.position, Quaternion.identity);
|
||||
optionPopupPanel.transform.position = popPose;
|
||||
optionPopupPanel.transform.LookAt(Camera.main.transform);
|
||||
optionPopupPanel.SetActive(true);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user