Last active
June 10, 2016 16:43
-
-
Save ShirakawaYoshimaru/90620945db861778d7328c51cbc8d727 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HogeSingleton | |
{ | |
private static HogeSingleton singleton = new HogeSingleton (); | |
private HogeSingleton () | |
{ | |
//初期化処理 | |
} | |
public static HogeSingleton Instance () | |
{ | |
return singleton; | |
} | |
public void Hoge() | |
{ | |
//todo | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class FugaSingleton : MonoBehaviour | |
{ | |
private static FugaSingleton singleton; | |
//初期化タイミングをAwake時にやる | |
void Awake () | |
{ | |
//MonoBehaviourを継承しているのでnewできない | |
singleton = this; | |
} | |
public static FugaSingleton Instance () | |
{ | |
return singleton; | |
} | |
public void Hoge() | |
{ | |
//todo | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main(){ | |
HogeSingleton.Instance ().Hello (); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment