【发布时间】:2018-03-16 22:47:53
【问题描述】:
我编写了自己的旋转一组对象的函数。我想做一个新的,旋转平稳,所以我需要一个计时器。我曾尝试调用 Timer 几次,但它不起作用。这是我的代码:
public class rotate_around : MonoBehaviour
{
public Transform sphere;
// Update is called once per frame
void Update ()
{
if (Input.GetKeyDown(KeyCode.RightArrow))
{
sphere.RotateAround(new Vector3(3, 3, 3), new Vector3(0, 1, 0), 45);
timer();
}
}
public IEnumerator timer()
{
yield return new WaitForSeconds(5);
// actually I tried to add Debug.Log("blahblahblah") here, but it still didnt output anything
}
}
【问题讨论】:
-
至少使用
timer().MoveNext();,否则不会调用你的方法和Debug.Log("blahblahblah")