unity创建单例模式,用按钮切换场景
private static GameMeaner _Instance;
//单例模式
public static GameMeaner Instance
{
get
{
if (_Instance == null)
{
_Instance = new GameMeaner();
}
return _Instance;
}
}
[System.Obsolete]
public void LoadScene(string sceneName)
{
Application.LoadLevel(sceneName);
}
public class GameMeaner
{
private static GameMeaner _Instance;
//单例模式
public static GameMeaner Instance
{
get
{
if (_Instance == null)
{
_Instance = new GameMeaner();
}
return _Instance;
}
}
[System.Obsolete]
public void LoadScene(string sceneName)
{
Application.LoadLevel(sceneName);
}
}