Files
AbdulandGitHub a2441db455 Update tiny samples to 0.29 preview (#14)
* Update tiny samples to 0.29 preview

* Add project settings
2020-08-25 21:23:11 -07:00

34 lines
980 B
C#

using Unity.Tiny.Input;
using Unity.Mathematics;
namespace Unity.TinyGems
{
public static class InputUtil
{
public static bool GetInputDown(InputSystem input)
{
if (input.IsMousePresent())
return input.GetMouseButtonDown(0);
return input.TouchCount() > 0 &&
input.GetTouch(0).phase == TouchState.Began;
}
public static bool GetInputUp(InputSystem input)
{
if (input.IsMousePresent())
return input.GetMouseButtonUp(0);
return input.TouchCount() > 0 &&
input.GetTouch(0).phase == TouchState.Ended;
}
public static float2 GetInputPosition(InputSystem input)
{
if (input.IsMousePresent())
return input.GetInputPosition();
return input.TouchCount() > 0 ? new float2(input.GetTouch(0).x, input.GetTouch(0).y) : float2.zero;
}
}
}