Exemple #1
0
        public static RunnerSettings LoadSettings()
        {
                        #if UNITY_EDITOR
            {
                if (!Directory.Exists(SETTING_DIRECTORY))
                {
                    Directory.CreateDirectory(SETTING_DIRECTORY);
                }

                if (!File.Exists(SETTING_FILE_PATH))
                {
                    File.CreateText(SETTING_FILE_PATH);
                }
            }
                        #endif

            var settingData    = Resources.Load(SETTING_FILE_NAME) as TextAsset;
            var settingDataStr = settingData.text;

            if (string.IsNullOrEmpty(settingDataStr))
            {
                                #if UNITY_EDITOR
                {
                    WriteSettings(new RunnerSettings());
                }
                                #endif
                staticSettings = new RunnerSettings();
                return(staticSettings);
            }

            staticSettings = JsonUtility.FromJson <RunnerSettings>(settingDataStr);
            return(staticSettings);
        }
Exemple #2
0
        public static void WriteSettings(RunnerSettings newSettings)
        {
            staticSettings = newSettings;
                        #if UNITY_EDITOR
            {
                var newSettingsStr = JsonUtility.ToJson(newSettings);

                using (var sw = new StreamWriter(SETTING_FILE_PATH)) {
                    sw.Write(newSettingsStr);
                }
            }
                        #endif
        }