public static void OnEditorOptionsChanged(Options.EditorOptions options) { var param = _highlightMaterial?.GetParam("Color"); if (param != null) { param.Value = options.Visual.HighlightColor; } }
/// <summary> /// Loads the settings from the file. /// </summary> public void Load() { Editor.Log("Loading editor options"); if (!File.Exists(_optionsFilePath)) { Editor.LogWarning("Missing editor settings"); return; } try { // Load asset var asset = FlaxEngine.Content.LoadAsync <JsonAsset>(_optionsFilePath); if (asset == null) { Editor.LogWarning("Invalid editor settings"); return; } if (asset.WaitForLoaded()) { Editor.LogError("Failed to load editor settings"); return; } // Deserialize data var assetObj = asset.CreateInstance(); if (assetObj is EditorOptions options) { // Add missing custom options foreach (var e in _customSettings) { if (!options.CustomSettings.ContainsKey(e.Key)) { options.CustomSettings.Add(e.Key, JsonSerializer.Serialize(e.Value())); } } Options = options; OnOptionsChanged(); Platform.CustomDpiScale = Options.Interface.InterfaceScale; } else { Editor.LogWarning("Failed to deserialize editor settings"); } } catch (Exception ex) { Editor.LogError("Failed to load editor options."); Editor.LogWarning(ex); } }
/// <summary> /// Loads the settings from the file. /// </summary> public void Load() { Editor.Log("Loading editor options"); try { // Load asset var asset = FlaxEngine.Content.LoadAsync <JsonAsset>(_optionsFilePath); if (asset == null) { Editor.LogWarning("Missing or invalid editor settings"); return; } if (asset.WaitForLoaded()) { Editor.LogWarning("Failed to load editor settings"); return; } // Deserialize data var assetObj = asset.CreateInstance(); if (assetObj is EditorOptions options) { Options = options; OnOptionsChanged(); } else { Editor.LogWarning("Failed to deserialize editor settings"); } } catch (Exception ex) { Editor.LogError("Failed to load editor options."); Editor.LogWarning(ex); } }
/// <summary> /// Applies the specified options and updates the dependant services. /// </summary> /// <param name="options">The new options.</param> public void Apply(EditorOptions options) { Options = options; OnOptionsChanged(); Save(); }