Unity/Csharp/シングルトン
提供: 初心者エンジニアの簡易メモ
2017年9月22日 (金) 23:51時点におけるAdmin (トーク | 投稿記録)による版 (ページの作成:「==MonoBehaviourを使ったシングルトン== using System.Collections; using System.Collections.Generic; using UnityEngine; public class KomaManager : MonoBehaviou...」)
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 () {
}
}
