Ejemplo n.º 1
0
            public static void OnEditorOptionsChanged(Options.EditorOptions options)
            {
                var param = _highlightMaterial?.GetParam("Color");

                if (param != null)
                {
                    param.Value = options.Visual.HighlightColor;
                }
            }
Ejemplo n.º 2
0
        /// <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);
            }
        }
Ejemplo n.º 3
0
        /// <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);
            }
        }
Ejemplo n.º 4
0
 /// <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();
 }