unity創(chuàng)建單例模式,用按鈕切換場(chǎng)景
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);
? ? }
}