【发布时间】:2022-01-15 10:47:39
【问题描述】:
我有这个 List<int> RecordedHR = new List<int>; 正在更新 FixedUpdate() 我想将它发送到另一个脚本,该脚本将计算它的平均值并将该平均值保存在我的 Firebase 实时数据库中。
public List<int> RecordedHR = new List<int>();
void FixedUpdate()
{
LIVEHRDATA.text = FirebaseManager.instance.GetLiveHR();
str = FirebaseManager.instance.GetLiveHR();
RecordedHR.Add(str);
if (str.Equals("Normal"))
{
punish = false;
count = 0;
}else if (str.Equals("High"))
{
count++;
Debug.Log("Count: "+count);
}
if(count >= 500 && count<750)
{
punish = true;
Debug.Log("PUNISH FLAG VALUE: " + punish);
}
if(count >= 750)
{
punish = false;
Debug.Log("PUNISH FLAG VALUE: " + punish);
AutoPause();
}
}
所以我在场景中实时获取数据,我想在场景切换后立即发送,我可以在 onDestroy() 上执行吗?
【问题讨论】:
-
不要使用 FixedUpdate - 它主要用于物理计算,使用 Update 代替
-
感谢您的推荐!但是我可以在填满后使用 on destroy 发送列表吗?
-
请使用正确的标签!请注意,
unityscript是或更好的是曾经是一种 JavaScript 风格,类似于早期 Unity 版本中使用的自定义语言,并且现在早已弃用了!您的代码显然在c#..