我正在为 Android 制作一个 2D Unity 游戏。请帮我实现鼠标控制(以便可以从手机上控制)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class qwe : MonoBehaviour
{
public float direction = 1f; // initial direction
public float speed = 20f; // speed of rotation
void Update ()
{
float angle = transform.eulerAngles.z;
if (angle > 180f) angle -= 360f;
if ((angle < -40f) || (angle > 40f)) direction *= -1f; // reverse direction (toggles between 1 & -1)
transform.Rotate (0, 0, speed * direction * Time.deltaTime);
}
}
要使用鼠标输入,您需要编写
if (Input.GetMouseButtonDown(0))
{
//your content here
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)