InvokeRepeating与.Net 4.6不一致

时间:2017-12-06 12:43:43

标签: 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 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)

有没有人知道发生了什么......我似乎无法发现任何错误。

屏幕截图 - enter image description here

1 个答案:

答案 0 :(得分:1)

这很有效 -

转到修改>项目设置>时间

Timescale has to be 1