Transforms input from screen point to world point.

This commit is contained in:
2022-11-06 13:20:26 +08:00
parent d58e255b3f
commit b92a21951d
5 changed files with 27 additions and 6 deletions

View File

@@ -57,8 +57,7 @@ namespace Cryville.Common.Unity.Input {
double time = Time.timeAsDouble;
for (int i = 0; i < unity::Input.touchCount; i++) {
var t = unity::Input.GetTouch(i);
Vector2 pos = t.position;
pos.y = Screen.height - pos.y;
Vector2 pos = UnityCameraUtils.ScreenToWorldPoint(t.position);
var vec = new InputVector(time, pos);
if (t.phase == TouchPhase.Began || t.phase == TouchPhase.Stationary || t.phase == TouchPhase.Moved) {
handler.Feed(0, t.fingerId, vec);