IEnumerator UVZero() {
float x = float.Parse(objs2[0].GetComponent
x += Time.deltaTime;
objs2[0].GetComponent
yield return null;
}
用了协程 但是数字每次增加不是0.1f
using UnityEngine;
public class Example : MonoBehaviour
{
float x = 0f;
private void Update()
{
//鼠标按住
if (Input.GetMouseButton(0))
{
x += .1f;
}
}
}
在update函数里添加鼠标左键监听事件,以下是3种事件,按你的需求应该是需要GetMouseButtonDown和GetMouseButtonUp两个事件
// 按下鼠标左键
if (Input.GetMouseButtonDown(0)) {
Debug.Log ("你按下了鼠标左键");
}
// 按住鼠标左键
if (Input.GetMouseButton(0)) {
Debug.Log ("你按住了鼠标左键");
}
// 抬起鼠标左键
if (Input.GetMouseButtonUp(0)) {
Debug.Log ("你抬起了鼠标左键");
}
Time.deltaTime 是增量时间,大小为1/每秒帧数 ,不是固定的0.1f
望采纳,不懂可以私信问我!