/// <summary> /// This initializes the GameApplication singleton as a blocking call - it means /// that access to Instance is valied immediately as this method returns. /// </summary> public static GameApplication CreateInstanceSync() { #if UNITY_EDITOR s_requestingScene = ""; #endif if (s_instance != null) { CoreLogger.LogError(LoggerModules.GameApplication, "calling GameApplication sync init while in async init - this is a serious error, unless in a special debug mode!!"); return(s_instance); } CoreLogger.LogDebug(LoggerModules.GameApplication, "creating GameApplication instance synchronously"); GameApplication instance = CreateOrGet(); if (instance == null) { CoreLogger.LogCritical(LoggerModules.GameApplication, "unable to obtain kernel instance!"); return(null); } if (!instance.AllowSynchronousCreation) { if (instance.synchronousCreationFallbackScene != null && instance.synchronousCreationFallbackScene != "") { CoreLogger.LogDebug(LoggerModules.GameApplication, string.Format("synchronous creation not allowed in this game - " + "reverting to scene {0}", instance.synchronousCreationFallbackScene)); string scene = instance.synchronousCreationFallbackScene; DestroyObject(instance.gameObject); #if UNITY_EDITOR GameApplication.Init(scene); #endif return(null); } CoreLogger.LogCritical(LoggerModules.GameApplication, "synchrnous creation not allowed in this Game!!!"); return(null); } IEnumerator steps = instance.Init(true); while (steps.MoveNext()) { } return(instance); }
public static void Init(string initSceneName) { if (s_instance != null) { return; } if (initSceneName == null || initSceneName == "") { CoreLogger.LogDebug(LoggerModules.GameApplication, "request to init GameApplication synchronously"); IGameApplication app = GameApplication.Instance; if (app == null) { CoreLogger.LogCritical(LoggerModules.GameApplication, "failed to create GameApplication!"); return; } } s_requestingScene = Application.loadedLevelName; Application.LoadLevel(initSceneName); }