2 回答

TA贡献1851条经验 获得超5个赞
我建议创建一个单独的脚本并将其附加到您的多维数据集。
public class CubeTracker : MonoBehaviour
{
private bool logging = true;
void Awake()
{
StartCoroutine(LogPosition());
}
private IEnumerator LogPosition()
{
while (logging)
{
Debug.Log(transform.position);
yield return new WaitForSeconds(3f);
}
}
}
这将在创建多维数据集后立即启动协程,并将所需的结果记录到控制台中。如果这是您想要的,那么您可以继续将 Debug.Log 替换为写入文件实现。

TA贡献1818条经验 获得超3个赞
使用全局变量,并在Update()方法中提供它。
例如:
private Vector3 LastCoordinate{get; set;}
并使用定期计时器,例如:
private System.Threading.Timer timer;
timer = new System.Threading.Timer(GetLastCoordinate, null, 3000, 0);
private void GetLastCoordinate()
{
lock(this)
{
Vector3 lastCoordEachThreeSecs = LastCoordinate;
}
}
- 2 回答
- 0 关注
- 215 浏览
添加回答
举报