コード例 #1
0
        private void InitializeSettings()
        {
            if (!File.Exists("settings.json"))
            {
                var config = new ModelViewerConfig();
                File.WriteAllText("settings.json", JsonConvert.SerializeObject(config, Formatting.Indented));
            }

            SettingsManager <ModelViewerConfig> .Initialize("settings.json");
        }
コード例 #2
0
        public static void Initialize(ModelViewerConfig config, GameObject loadScreen)
        {
            loadingScreen = loadScreen;

            var progressBar = loadingScreen.GetComponentInChildren <ProgressBar>();

            progressBar.SetStatus("Initializing CASC Storage", 0);

            cascWorker = new BackgroundWorker {
                WorkerReportsProgress = true
            };
            cascWorker.DoWork             += CascWorkerOnDoWork;
            cascWorker.ProgressChanged    += CascWorkerOnProgressChanged;
            cascWorker.RunWorkerCompleted += CascWorkerOnRunWorkerCompleted;
            cascWorker.RunWorkerAsync(config);
        }
コード例 #3
0
        private void OnSaveSettings()
        {
            var config = new ModelViewerConfig
            {
                LoadType     = (CascLoadType)LoadType.value,
                LocalBranch  = LocalBranch.options[LocalBranch.value].text,
                LocalStorage = LocalPath.text,
                OnlineBranch = onlineBranches[OnlineBranch.value]
            };

            // Check if the config is the same as the loaded config.
            if (config != SettingsManager <ModelViewerConfig> .Config)
            {
                // Replace all the contents of settings with the new settings
                // and reload the SettingsManager with the new settings.
                File.WriteAllText("settings.json", JsonConvert.SerializeObject(config, Formatting.Indented));
                SettingsManager <ModelViewerConfig> .Initialize("settings.json");
            }

            // Close the settings window.
            OnSettingsClose();
        }