Loads the settings from the file.
()
| 93 | /// Loads the settings from the file. |
| 94 | /// </summary> |
| 95 | public void Load() |
| 96 | { |
| 97 | Editor.Log("Loading editor options"); |
| 98 | if (!File.Exists(_optionsFilePath)) |
| 99 | { |
| 100 | Editor.LogWarning("Missing editor settings"); |
| 101 | return; |
| 102 | } |
| 103 | |
| 104 | try |
| 105 | { |
| 106 | // Load asset |
| 107 | var asset = FlaxEngine.Content.LoadAsync<JsonAsset>(_optionsFilePath); |
| 108 | if (asset == null) |
| 109 | { |
| 110 | Editor.LogWarning("Invalid editor settings"); |
| 111 | return; |
| 112 | } |
| 113 | if (asset.WaitForLoaded()) |
| 114 | { |
| 115 | Editor.LogError("Failed to load editor settings"); |
| 116 | return; |
| 117 | } |
| 118 | |
| 119 | // Deserialize data |
| 120 | var assetObj = asset.CreateInstance(); |
| 121 | if (assetObj is EditorOptions options) |
| 122 | { |
| 123 | // Add missing custom options |
| 124 | foreach (var e in _customSettings) |
| 125 | { |
| 126 | if (!options.CustomSettings.ContainsKey(e.Key)) |
| 127 | options.CustomSettings.Add(e.Key, JsonSerializer.Serialize(e.Value())); |
| 128 | } |
| 129 | |
| 130 | float prevInterfaceScale = Options.Interface.InterfaceScale; |
| 131 | Options = options; |
| 132 | OnOptionsChanged(); |
| 133 | |
| 134 | // Scale interface relative to the current value (eg. when using system-provided Dpi Scale) |
| 135 | Platform.CustomDpiScale *= Options.Interface.InterfaceScale / prevInterfaceScale; |
| 136 | } |
| 137 | else |
| 138 | { |
| 139 | Editor.LogWarning("Failed to deserialize editor settings"); |
| 140 | } |
| 141 | } |
| 142 | catch (Exception ex) |
| 143 | { |
| 144 | Editor.LogError("Failed to load editor options."); |
| 145 | Editor.LogWarning(ex); |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | /// <summary> |
| 150 | /// Applies the specified options and updates the dependant services. |
nothing calls this directly
no test coverage detected