点击预览位置,alt——上下挪动位置

Signed-off-by: TRAfoer <lhf190@outlook.com>
This commit is contained in:
2026-02-13 17:40:50 +08:00
parent c21dc74576
commit 96a2c60e16
34 changed files with 23940 additions and 211416 deletions

View File

@@ -95,15 +95,10 @@ public class PanelDrawer : MonoBehaviour //暂时支持xz
public Canvas DisplayCanvas;
private IEnumerator Pressing()
{
GameObject gobj = new GameObject("PanelDrawerPreview");
RawImage rawImage = gobj.AddComponent<RawImage>();
GameObject gobj2 = new GameObject("PanelDrawerText");
gobj2.transform.SetParent(gobj.transform, false);
gobj2.transform.SetParent(DisplayCanvas.transform, false);
TextMeshProUGUI Text = gobj2.AddComponent<TextMeshProUGUI>();
Text.rectTransform.position = new Vector3(50, 50, 0);
rawImage.texture = ingTexture;
rawImage.rectTransform.SetParent(DisplayCanvas.transform);
rawImage.rectTransform.sizeDelta = new Vector2(100, 100);
Vector3 hitPoint = new Vector3(0, 0, 0);
while (Mouse.current.leftButton.isPressed)
{
@@ -117,21 +112,23 @@ public class PanelDrawer : MonoBehaviour //暂时支持xz
if (Keyboard.current.leftAltKey.isPressed)
{
hitPoint = new Vector3(Mathf.Round(hitPoint.x / 0.5f) * 0.5f, hitPoint.y, Mathf.Round(hitPoint.z / 0.5f) * 0.5f);
rawImage.rectTransform.position =
new Vector3(Mathf.Round(Mouse.current.position.ReadValue().x / 10) * 10, Mathf.Round(Mouse.current.position.ReadValue().y / 10) * 10, 0);
}
else
{
rawImage.rectTransform.position = Mouse.current.position.ReadValue();
}
Text.text = $"X: {hitPoint.x:F2}\nY: {hitPoint.y:F2}\nZ: {hitPoint.z:F2}";
Text.rectTransform.position = Mouse.current.position.ReadValue() + new Vector2(20, -20);
Text.text = $"X: {hitPoint.x:F2}\nZ: {hitPoint.z:F2}\n\n";
Text.fontSize = 45;
Text.color = Color.yellow;
}
yield return null;
}
Destroy(rawImage.gameObject);
Destroy(Text.gameObject);
var i = PathNode.GenerateElement("new pathnode", Guid.NewGuid(), new List<string>(), true, (Track)connectedGameElement, true);
i.transformSubmodule.originalPosition = hitPoint;
i.transform.position = hitPoint;
i.transformSubmodule.originalPosition = i.transform.localPosition;
i.Refresh();
connectedGameElement.Refresh();
}