「Unity/Csharp/シングルトン」の版間の差分
提供: 初心者エンジニアの簡易メモ
(ページの作成:「==MonoBehaviourを使ったシングルトン== using System.Collections; using System.Collections.Generic; using UnityEngine; public class KomaManager : MonoBehaviou...」) |
(相違点なし)
|
2017年9月22日 (金) 23:51時点における版
MonoBehaviourを使ったシングルトン
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class KomaManager : MonoBehaviour {
private static KomaManager mInstance;
public int x = 1;
private KomaManager () {
}
public static KomaManager Instance {
get {
if( mInstance == null ) {
GameObject go = new GameObject("KomaManager");
mInstance = go.AddComponent<KomaManager>();
}
return mInstance;
}
}
void Start () {
}
void Update () {
}
}
