use new input system

This commit is contained in:
SepComet
2026-04-30 14:52:19 +08:00
parent a38a8d4b39
commit 1422db3b19
4 changed files with 37 additions and 26 deletions
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.UI;
using UnityGameFramework.Runtime;
@@ -39,7 +40,7 @@ namespace GeometryTD.UI
[SerializeField] private float _sideGap = 16f;
[SerializeField] private float _anchorItemWidth = 0f;
private readonly List<GameObject> _runtimeTagItems = new List<GameObject>();
private ItemDescFormContext _context;
@@ -78,7 +79,7 @@ namespace GeometryTD.UI
{
base.OnOpen(userData);
_isOpened = true;
if (!(userData is ItemDescFormContext context))
{
Log.Error("ItemDescFormContext is invalid.");
@@ -360,24 +361,27 @@ namespace GeometryTD.UI
private static bool TryGetPointerDownScreenPosition(out Vector2 screenPoint)
{
if (Input.touchCount > 0)
Touchscreen touchscreen = Touchscreen.current;
if (touchscreen != null)
{
for (int i = 0; i < Input.touchCount; i++)
var touches = touchscreen.touches;
for (int i = 0; i < touches.Count; i++)
{
Touch touch = Input.GetTouch(i);
if (touch.phase != TouchPhase.Began)
var touch = touches[i];
if (!touch.press.wasPressedThisFrame)
{
continue;
}
screenPoint = touch.position;
screenPoint = touch.position.ReadValue();
return true;
}
}
if (Input.GetMouseButtonDown(0))
Mouse mouse = Mouse.current;
if (mouse != null && mouse.leftButton.wasPressedThisFrame)
{
screenPoint = Input.mousePosition;
screenPoint = mouse.position.ReadValue();
return true;
}