移动端InputAxis输入检测
//0,-1,1
public Vector3 MoibleInputAxisRaw
{
get
{
Vector3 temp = Vector3.zero;
if (MoibleInputAxis.x > 0)
{
temp.x = 1;
} else if (MoibleInputAxis.x< 0)
{
temp.x = -1;
}
if (MoibleInputAxis.y > 0)
{
temp.y = 1;
}
else if (MoibleInputAxis.y < 0)
{
temp.y = -1;
}
if (MoibleInputAxis.z > 0)
{
temp.z = 1;
}
else if (MoibleInputAxis.x < 0)
{
temp.z = -1;
}
return temp;
}
}
public Vector3 MoibleInputAxis;//-1f----1f
Vector3 BeginPoint;
private void Awake()
{
Instance = this;
}
private void Update()
{
if (Input.GetMouseButtonDown(0))
{
BeginPoint =Camera.main.ScreenToViewportPoint(Input.mousePosition);
}
if (Input.GetMouseButton(0))
{
MoibleInputAxis = (Camera.main.ScreenToViewportPoint(Input.mousePosition)- BeginPoint).normalized;
}
if (Input.GetMouseButtonUp(0))
{
MoibleInputAxis = Vector3.zero;
}
}
|