добавил двойное нажатие для ред обьектов
This commit is contained in:
parent
670930c78e
commit
b773b20b19
@ -17,6 +17,9 @@ public class FurnitureController : MonoBehaviour
|
|||||||
[SerializeField] private GameObject editPanel;
|
[SerializeField] private GameObject editPanel;
|
||||||
[SerializeField] private GameObject rotate90Button;
|
[SerializeField] private GameObject rotate90Button;
|
||||||
public float rotationSpeed = 5f;
|
public float rotationSpeed = 5f;
|
||||||
|
|
||||||
|
[Header("Настройки двойного клика")]
|
||||||
|
public float doubleClickThreshold = 0.3f; // Максимальное время между кликами в секундах
|
||||||
|
|
||||||
[Header("Связь с камерой")]
|
[Header("Связь с камерой")]
|
||||||
public MonoBehaviour cameraController;
|
public MonoBehaviour cameraController;
|
||||||
@ -29,6 +32,8 @@ public class FurnitureController : MonoBehaviour
|
|||||||
private bool _isInteracting = false;
|
private bool _isInteracting = false;
|
||||||
private Vector3 _lastInputPos;
|
private Vector3 _lastInputPos;
|
||||||
private Vector3 _dragOffset;
|
private Vector3 _dragOffset;
|
||||||
|
|
||||||
|
private float _lastClickTime = 0f; // Хранит время последнего клика
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
@ -49,13 +54,25 @@ public class FurnitureController : MonoBehaviour
|
|||||||
}
|
}
|
||||||
else if (currentPrefab != null)
|
else if (currentPrefab != null)
|
||||||
{
|
{
|
||||||
|
// Оставляем одинарный клик для установки НОВОЙ мебели
|
||||||
if (Input.GetMouseButtonDown(0) && !shopPanel.activeSelf && !IsPointerOverUI())
|
if (Input.GetMouseButtonDown(0) && !shopPanel.activeSelf && !IsPointerOverUI())
|
||||||
TryPlaceFurniture();
|
TryPlaceFurniture();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// Логика двойного клика для выбора УЖЕ УСТАНОВЛЕННОЙ мебели
|
||||||
if (Input.GetMouseButtonDown(0) && !shopPanel.activeSelf && !IsPointerOverUI())
|
if (Input.GetMouseButtonDown(0) && !shopPanel.activeSelf && !IsPointerOverUI())
|
||||||
TrySelectPlacedFurniture();
|
{
|
||||||
|
float timeSinceLastClick = Time.time - _lastClickTime;
|
||||||
|
|
||||||
|
if (timeSinceLastClick <= doubleClickThreshold)
|
||||||
|
{
|
||||||
|
// Если время между кликами меньше порога — это двойной клик
|
||||||
|
TrySelectPlacedFurniture();
|
||||||
|
}
|
||||||
|
|
||||||
|
_lastClickTime = Time.time; // Запоминаем время текущего клика
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user