我将以下脚本附加到相机
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Sample : MonoBehaviour {
int i=0;
void Start () {
Debug.Log("This is printed immediately");
Debug.Log("Called invoke repating ");
InvokeRepeating("test", 0.0f, 0.5f);
}
void test()
{
i++;
Debug.Log("Called invoke repating "+i);
}
void Update () {
}
}
这是我在我的控制台中得到的东西(停止并且不会反复调用):
This is printed immediately
UnityEngine.Debug:Log(Object)
Sample:Start() (at Assets/Sample.cs:27)
Called invoke repating
UnityEngine.Debug:Log(Object)
Sample:Start() (at Assets/Sample.cs:28)
Called invoke repating 1
UnityEngine.Debug:Log(Object)
Sample:test() (at Assets/Sample.cs:36)
有没有人知道发生了什么......我似乎无法发现任何错误。
答案 0 :(得分:1)
这很有效 -
转到修改>项目设置>时间强>
Timescale has to be 1