/// <summary> /// Exit the application /// </summary> public void OnExit() { Log.Debug(string.Format("MenuActions.OnExit()")); ApplicationHelper.Quit(); }
/// <summary> /// Initialize happens on Awake for new Singletons /// </summary> protected override void Initialize() { Log.Verbose(string.Format("GameManager.Initialize() ID={0}", GetInstanceID())); base.Initialize(); // signal loading state State = GameState.Loading; // App starts focused Focused = true; // create settings at their defaults ApplicationSettings = new ApplicationSettings(); // // DOTween // // initialize with the preferences set in DOTween's Utility Panel DOTween.Init(); // // Newtonsoft.Json default serialization settings // // http://www.newtonsoft.com/json/help/html/SerializationSettings.htm JsonConvert.DefaultSettings = (() => new JsonSerializerSettings { // add '$type' only if needed. // NOTE: Can't use Binder in NET35 || NET20 TypeNameHandling = TypeNameHandling.Auto, // don't write properties at default values, use // [System.ComponentModel.DefaultValue(x)] to mark defaults that cannot // be directly determined naturally, i.e. int defaults to 0. DefaultValueHandling = DefaultValueHandling.Ignore, Converters = { new StringEnumConverter { CamelCaseText = false } }, // The default is to write all keys in camelCase. This can be overridden at // the field/property level using attributes ContractResolver = new CamelCasePropertyNamesContractResolver(), // pretty print Formatting = Formatting.Indented, }); // read command line options if (ApplicationHelper.IsDesktop()) { string[] args = System.Environment.GetCommandLineArgs(); string commandLine = string.Join(" ", args); foreach (string arg in args) { // store all settings the given folder if (Regex.IsMatch(arg, @"--settings-folder")) { // This handles quoted paths with spaces but leaves the quotes in place Regex regex = new Regex(@"--settings-folder\s+(?<path>[\""].+?[\""]|[^ ]+)"); Match match = regex.Match(commandLine); if (match.Success) { string path = match.Groups["path"].Value; if (!Path.IsPathRooted(path)) { // convert to absolute path path = Path.Combine(Directory.GetCurrentDirectory(), path); } if (Directory.Exists(path)) { Log.Debug(string.Format("GameManager.Initialize() Settings.DataPath: {0}", path)); Settings.DataPath = path; } else { Log.Error(string.Format("GameManager.Initialize() requested settings folder {0} does not exist", path)); } } } } } // load the data, defaults to empty string string json = Settings.GetString(SettingsKey.Application); if (json != "") { DeserializeSettings(json); } #if JAMER_LOG_DEBUG LogLevels |= LogLevels.Debug; #endif #if JAMMER_LOG_VERBOSE LogLevels |= LogLevels.Verbose; #endif #if JAMMER_CONSOLE // log debug console from resources CreatePrefab(name: "Console"); #endif }