Refactor various Editor APIs to use auto-generated bindings instead of manual code

This commit is contained in:
Wojtek Figat
2023-06-12 14:34:07 +02:00
parent 7140c4a2d8
commit 979168e82c
26 changed files with 611 additions and 1899 deletions

View File

@@ -144,7 +144,7 @@ namespace FlaxEditor.Windows.Assets
Asset = window.Asset;
// Try to restore target asset import options (useful for fast reimport)
ModelImportSettings.TryRestore(ref ImportSettings, window.Item.Path);
Editor.TryRestoreImportOptions(ref ImportSettings.Settings, window.Item.Path);
}
public void OnClean()

View File

@@ -27,7 +27,7 @@ namespace FlaxEditor.Windows.Assets
private CubeTextureWindow _window;
[EditorOrder(1000), EditorDisplay("Import Settings", EditorDisplayAttribute.InlineStyle)]
public TextureImportSettings ImportSettings = new TextureImportSettings();
public FlaxEngine.Tools.TextureTool.Options ImportSettings = new();
public sealed class ProxyEditor : GenericEditor
{
@@ -69,7 +69,7 @@ namespace FlaxEditor.Windows.Assets
_window = window;
// Try to restore target asset texture import options (useful for fast reimport)
TextureImportSettings.TryRestore(ref ImportSettings, window.Item.Path);
Editor.TryRestoreImportOptions(ref ImportSettings, window.Item.Path);
// Prepare restore data
PeekState();

View File

@@ -11,6 +11,7 @@ using FlaxEditor.Viewport.Cameras;
using FlaxEditor.Viewport.Previews;
using FlaxEngine;
using FlaxEngine.GUI;
using FlaxEngine.Tools;
using FlaxEngine.Utilities;
using Object = FlaxEngine.Object;
@@ -196,12 +197,12 @@ namespace FlaxEditor.Windows.Assets
group.Label("No SDF");
}
var resolution = group.FloatValue("Resolution Scale", proxy.Window.Editor.CodeDocs.GetTooltip(typeof(ModelImportSettings), nameof(ModelImportSettings.SDFResolution)));
var resolution = group.FloatValue("Resolution Scale", proxy.Window.Editor.CodeDocs.GetTooltip(typeof(ModelTool.Options), nameof(ModelImportSettings.Settings.SDFResolution)));
resolution.ValueBox.MinValue = 0.0001f;
resolution.ValueBox.MaxValue = 100.0f;
resolution.ValueBox.Value = sdf.Texture != null ? sdf.ResolutionScale : 1.0f;
resolution.ValueBox.BoxValueChanged += b => { proxy.Window._importSettings.SDFResolution = b.Value; };
proxy.Window._importSettings.SDFResolution = sdf.ResolutionScale;
resolution.ValueBox.BoxValueChanged += b => { proxy.Window._importSettings.Settings.SDFResolution = b.Value; };
proxy.Window._importSettings.Settings.SDFResolution = sdf.ResolutionScale;
var backfacesThreshold = group.FloatValue("Backfaces Threshold", "Custom threshold (in range 0-1) for adjusting mesh internals detection based on the percentage of test rays hit triangle backfaces. Use lower value for more dense mesh.");
backfacesThreshold.ValueBox.MinValue = 0.001f;
@@ -293,7 +294,7 @@ namespace FlaxEditor.Windows.Assets
private void OnRebuildSDF()
{
var proxy = (MeshesPropertiesProxy)Values[0];
proxy.Asset.GenerateSDF(proxy.Window._importSettings.SDFResolution, _sdfModelLodIndex.Value, true, proxy.Window._backfacesThreshold);
proxy.Asset.GenerateSDF(proxy.Window._importSettings.Settings.SDFResolution, _sdfModelLodIndex.Value, true, proxy.Window._backfacesThreshold);
proxy.Window.MarkAsEdited();
Presenter.BuildLayoutOnUpdate();
}
@@ -919,7 +920,7 @@ namespace FlaxEditor.Windows.Assets
{
_refreshOnLODsLoaded = true;
_preview.ViewportCamera.SetArcBallView(Asset.GetBox());
ModelImportSettings.TryRestore(ref _importSettings, Item.Path);
Editor.TryRestoreImportOptions(ref _importSettings.Settings, Item.Path);
UpdateEffectsOnAsset();
// TODO: disable streaming for this model

View File

@@ -986,7 +986,7 @@ namespace FlaxEditor.Windows.Assets
{
base.OnLoad(window);
ModelImportSettings.TryRestore(ref ImportSettings, window.Item.Path);
Editor.TryRestoreImportOptions(ref ImportSettings.Settings, window.Item.Path);
}
public void Reimport()

View File

@@ -103,7 +103,7 @@ namespace FlaxEditor.Windows.Assets
public SpriteEntry[] Sprites;
[EditorOrder(1000), EditorDisplay("Import Settings", EditorDisplayAttribute.InlineStyle)]
public TextureImportSettings ImportSettings = new TextureImportSettings();
public FlaxEngine.Tools.TextureTool.Options ImportSettings = new();
public sealed class ProxyEditor : GenericEditor
{
@@ -183,11 +183,7 @@ namespace FlaxEditor.Windows.Assets
UpdateSprites();
// Try to restore target asset texture import options (useful for fast reimport)
if (TextureImportEntry.Internal_GetTextureImportOptions(win.Item.Path, out TextureImportSettings.InternalOptions options))
{
// Restore settings
ImportSettings.FromInternal(ref options);
}
Editor.TryRestoreImportOptions(ref ImportSettings, win.Item.Path);
// Prepare restore data
PeekState();

View File

@@ -70,7 +70,7 @@ namespace FlaxEditor.Windows.Assets
internal TextureWindow _window;
[EditorOrder(1000), EditorDisplay("Import Settings", EditorDisplayAttribute.InlineStyle)]
public TextureImportSettings ImportSettings = new TextureImportSettings();
public FlaxEngine.Tools.TextureTool.Options ImportSettings = new();
/// <summary>
/// Gathers parameters from the specified texture.
@@ -82,7 +82,7 @@ namespace FlaxEditor.Windows.Assets
_window = window;
// Try to restore target asset texture import options (useful for fast reimport)
TextureImportSettings.TryRestore(ref ImportSettings, window.Item.Path);
Editor.TryRestoreImportOptions(ref ImportSettings, window.Item.Path);
// Prepare restore data
PeekState();