예제 #1
0
 /// <summary>
 /// Removes the instance of the GameOptions if the instance being destroyed is the the same as the singleton.
 /// </summary>
 /// <param name="aInstance"></param>
 private static void DestroyInstance(GameOptions aInstance)
 {
     if (s_Instance == aInstance)
     {
         s_Instance = null;
     }
 }
예제 #2
0
 /// <summary>
 /// Sets the instance of the GameOptions to the instance given.
 /// </summary>
 /// <param name="aInstance">The instance to make singleton</param>
 /// <returns></returns>
 private static bool SetInstance(GameOptions aInstance)
 {
     if (s_Instance != null && s_Instance != aInstance)
     {
         return false;
     }
     s_Instance = aInstance;
     return true;
 }
예제 #3
0
 /// <summary>
 /// Creates an instance of the GameOptions if it was missing.
 /// </summary>
 private static void CreateInstance()
 {
     GameObject persistant = GameObject.Find(Game.PERSISTANT_GAME_OBJECT_NAME);
     if (persistant == null)
     {
         persistant = new GameObject(Game.PERSISTANT_GAME_OBJECT_NAME);
         persistant.transform.position = Vector3.zero;
         persistant.transform.rotation = Quaternion.identity;
     }
     s_Instance = persistant.GetComponent<GameOptions>();
     if (s_Instance == null)
     {
         s_Instance = persistant.AddComponent<GameOptions>();
     }
 }