【发布时间】:2019-06-26 17:39:22
【问题描述】:
嗨,为什么这不起作用 我正在尝试从函数运行的 cororotine 旋转游戏对象,但如果我将旋转放入更新中,它运行良好我很困惑感谢任何帮助
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class waitthendosomthing : MonoBehaviour
{
public bool beingHandled = true; // bool
void Update()
{
//transform.Rotate(6, 0, 0);// this runs
if (beingHandled == true )
{
StartCoroutine(HandleIt());// run function
}
}
void rotateit()
{
transform.Rotate(6, 0, 0);// this dosnt run
print("running this function");
}
IEnumerator HandleIt()
{
beingHandled = false;
print("BeingHandled is off");
rotateit();
//transform.Rotate(6, 0, 0); // or this
yield return new WaitForSeconds(3.1f);
//transform.Rotate(0, 0, 0); // or this
yield return new WaitForSeconds(3.1f);
beingHandled = true;
print("BeingHandled is on");
}
}
【问题讨论】: