注意:更改了trackpercentpoint的逻辑

Signed-off-by: TRAfoer <lhf190@outlook.com>
This commit is contained in:
2025-08-31 15:27:02 +08:00
parent 84ff356427
commit 27b3cf58d0
40 changed files with 288899 additions and 18281 deletions

View File

@@ -20,6 +20,8 @@ namespace Ichni.Editor
public GameObject hoveredUI;
public EventSystem eventSystem;
public List<GraphicRaycaster> graphicRaycasters;
private List<SelectionConnector> lastHitConnectors = new List<SelectionConnector>();
private int currentSelectIndex = 0;
private void Awake()
{
@@ -260,15 +262,31 @@ namespace Ichni.Editor
private void ClickSelectElement()
{
if (Mouse.current.leftButton.wasPressedThisFrame && !isPointerOverUI)
{
Vector2 mousePosition = Mouse.current.position.ReadValue();
Ray ray = EditorManager.instance.cameraManager.currentCamera.ScreenPointToRay(mousePosition);
if (Physics.Raycast(ray, out RaycastHit hit, float.MaxValue, LayerMask.GetMask("Selectable")))
RaycastHit[] hits = Physics.RaycastAll(ray, 500f, LayerMask.GetMask("Selectable"));
var hitConnectors = hits
.Select(hit => hit.collider.GetComponent<SelectionConnector>())
.Where(connector => connector != null)
.ToList();
if (hitConnectors.Count == 0) return;
// 如果点击对象列表变化,重置索引
if (!Enumerable.SequenceEqual(hitConnectors, lastHitConnectors))
{
SelectionConnector connector = hit.collider.GetComponent<SelectionConnector>();//TODO: 对于Hold这种复杂的元素需要使用连接脚本进行获取
(connector.connectedGameElement as IHaveSelectSubmodule)?.selectSubmodule.SelectGameElement();
lastHitConnectors = hitConnectors;
currentSelectIndex = 0;
}
var connector = lastHitConnectors[currentSelectIndex];
(connector.connectedGameElement as IHaveSelectSubmodule)?.selectSubmodule.SelectGameElement();
currentSelectIndex = (currentSelectIndex + 1) % lastHitConnectors.Count;
}
}
}