InputField 입력 시 GetKey 이벤트가 호출되는 문제, Hierarchy에서 객체 클릭 시 해당 객체로 카메라 이동

This commit is contained in:
geondo55
2025-06-24 10:58:18 +09:00
parent 9496e73df1
commit 144a905460
5 changed files with 34 additions and 5 deletions

View File

@@ -14,8 +14,10 @@ namespace Studio.Manage
viewAngle = new Vector3(45, 145, 0);
}
public void MoveToTwinObjectPos(TwinObject target)
public void MoveToTwinObjectPos(GameObject target)
{
if (target == null)
return;
var command = new MoveToTargetCommand(target.transform, viewAngle, cameraDistance);
CommandInvoker.instance.Invoke(command);
}

View File

@@ -1,7 +1,9 @@
using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using XRLib;
namespace Studio.Manage
@@ -106,6 +108,9 @@ namespace Studio.Manage
}
void Update()
{
if (IsEditInputField())
return;
foreach (var key in downKeyActionTable.Keys)
{
if (Input.GetKeyDown(key))
@@ -149,5 +154,15 @@ namespace Studio.Manage
updateLoop?.Invoke();
}
bool IsEditInputField()
{
GameObject selectedObj = EventSystem.current.currentSelectedGameObject;
if (selectedObj == null)
return false;
return selectedObj.GetComponent<TMP_InputField>() != null;
}
}
}

View File

@@ -30,7 +30,7 @@ namespace Studio.UI
public void CreateContentButton((TwinObject, TwinObject) pair)
{
var newButton = Object.Instantiate(buttonPrefab, content).GetComponent<UI_InterferedObjectButton>();
newButton.OnClickButton += cameraManager.MoveToTwinObjectPos;
//newButton.OnClickButton += cameraManager.MoveToTwinObjectPos;
newButton.Initialize(pair.Item1, pair.Item2);
createdButtons.Add(pair, newButton);
}

View File

@@ -6,6 +6,7 @@ using UnityEngine.Events;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using Studio.UI;
using Studio.Manage;
namespace Studio.HierarchyTree
{
@@ -24,6 +25,9 @@ namespace Studio.HierarchyTree
private HierarchyScrollItemUI hoverItemUI;
private Coroutine coroutinePendPopup;
public UnityEvent<HierarchyItem> onExit;
private float lastClickTime = 0f;
private const float doubleClickInterval = 0.3f;
public override void OnBeginDrag(PointerEventData eventData)
{
if (eventData.button != PointerEventData.InputButton.Left)
@@ -83,8 +87,6 @@ namespace Studio.HierarchyTree
}
}
public override void OnEndDrag(PointerEventData eventData)
{
if (eventData.button == PointerEventData.InputButton.Left)
@@ -142,19 +144,29 @@ namespace Studio.HierarchyTree
base.OnEndDrag(eventData);
}
}
public void OnPointerDown(PointerEventData eventData)
{
if (eventData.button == PointerEventData.InputButton.Left)
{
HierarchyScrollItemUI itemUI = GetTargetItemUI(eventData);
if (itemUI != null)
{
sourceItem = itemUI.currentItem;
float timeSinceLastClick = Time.time - lastClickTime;
if (timeSinceLastClick <= doubleClickInterval)
{
ManagerHub.instance.Get<CameraManager>().MoveToTwinObjectPos(sourceItem.linkedObject);
}
}
if (sourceItem != null)
{
coroutinePendPopup = StartCoroutine(CoroutinePendPopup());
}
lastClickTime = Time.time;
}
}
public void OnPointerUp(PointerEventData eventData)