C# 调用重复与.Net 4.6不一致
我将下面的脚本附加到相机上C# 调用重复与.Net 4.6不一致,c#,unity3d,C#,Unity3d,我将下面的脚本附加到相机上 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
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 () {
}
}
这是我在控制台中得到的结果(它停止并且不会被重复调用):
有人知道发生了什么事吗。。。我似乎看不出这里有什么错误
屏幕截图-这起作用了-
转到编辑>项目设置>时间
时间刻度必须为1
根据您的日志,它正在工作。它所做的正是您在代码中告诉它要做的。你不工作是什么意思?你期望什么?它必须重复它自己,但显然不是。。应该继续递增,但在1处停止。当控制台选项卡停止工作时,您可以发布其屏幕截图吗?我想看看发生了什么。在你问我感兴趣的时候添加了截图。相机对象停止工作时是否已停用?问是因为截图切断了那部分。
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)