Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/325.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
延迟c#unity 3d中的负载级别_C#_Unity3d - Fatal编程技术网

延迟c#unity 3d中的负载级别

延迟c#unity 3d中的负载级别,c#,unity3d,C#,Unity3d,我已经创建了一些代码,用于在用户完成后20秒加载下一个级别,但是我收到一个错误“需要对象引用才能访问静态功能”,但是我需要该功能是静态的,以便在直升机门打开并且用户可以进入直升机时能够调用它。有人能帮忙吗 using UnityEngine; using System.Collections; public class GameManager : MonoBehaviour { static bool _hasPlayerWon = false; public s

我已经创建了一些代码,用于在用户完成后20秒加载下一个级别,但是我收到一个错误“需要对象引用才能访问静态功能”,但是我需要该功能是静态的,以便在直升机门打开并且用户可以进入直升机时能够调用它。有人能帮忙吗

    using UnityEngine;
using System.Collections;

public class GameManager : MonoBehaviour {


    static bool _hasPlayerWon = false;

    public static bool HasPlayerWon {get{return _hasPlayerWon;}}

    Health _playerHealth;




    public static void WinPlayer()
    {

        _hasPlayerWon = true;
        Invoke("loadSplash",20.0f);

    }


    void loadSplash ()
    {
        Application.LoadLevel("splash1");

    }


}

创建一个包含对GameManager的引用的字段,并使用触发加载的方法调用协同程序

大概是这样的:

static private GameManager instance;

void Awake()
{
    instance = this;
}

public static void WinPlayer()
{
    _hasPlayerWon = true;
    instance.LoadLevel();
}

private void LoadLevel()
{
  StartCoroutine( LoadCo() );
}

private IEnumerator LoadCo()
{
  yield return new WaitForSeconds( 20.0 );

  Application.LoadLevel("splash1");
}

创建一个包含对GameManager的引用的字段,并使用触发加载的方法调用协同程序

大概是这样的:

static private GameManager instance;

void Awake()
{
    instance = this;
}

public static void WinPlayer()
{
    _hasPlayerWon = true;
    instance.LoadLevel();
}

private void LoadLevel()
{
  StartCoroutine( LoadCo() );
}

private IEnumerator LoadCo()
{
  yield return new WaitForSeconds( 20.0 );

  Application.LoadLevel("splash1");
}

创建一个包含对GameManager的引用的字段,并使用触发加载的方法调用协同程序

大概是这样的:

static private GameManager instance;

void Awake()
{
    instance = this;
}

public static void WinPlayer()
{
    _hasPlayerWon = true;
    instance.LoadLevel();
}

private void LoadLevel()
{
  StartCoroutine( LoadCo() );
}

private IEnumerator LoadCo()
{
  yield return new WaitForSeconds( 20.0 );

  Application.LoadLevel("splash1");
}

创建一个包含对GameManager的引用的字段,并使用触发加载的方法调用协同程序

大概是这样的:

static private GameManager instance;

void Awake()
{
    instance = this;
}

public static void WinPlayer()
{
    _hasPlayerWon = true;
    instance.LoadLevel();
}

private void LoadLevel()
{
  StartCoroutine( LoadCo() );
}

private IEnumerator LoadCo()
{
  yield return new WaitForSeconds( 20.0 );

  Application.LoadLevel("splash1");
}