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