Fix materials parameters display issues after editing

This commit is contained in:
Wojtek Figat
2021-08-18 22:55:31 +02:00
parent 540643972a
commit fff2c3e038
5 changed files with 43 additions and 31 deletions

View File

@@ -186,7 +186,6 @@ namespace FlaxEditor.Windows.Assets
// Asset properties proxy
_properties = new PropertiesProxy();
_propertiesEditor.Select(_properties);
// Preview properties editor
_previewTab = new Tab("Preview");
@@ -322,22 +321,17 @@ namespace FlaxEditor.Windows.Assets
{
if (value == null)
{
// Error
Editor.LogError("Failed to save animation graph surface");
return;
}
// Save data to the temporary asset
if (_asset.SaveSurface(value))
{
// Error
_surface.MarkAsEdited();
Editor.LogError("Failed to save animation graph surface data");
return;
}
_asset.Reload();
// Reset any root motion
_asset.WaitForLoaded();
_preview.PreviewActor.ResetLocalTransform();
_previewTab.Presenter.BuildLayoutOnUpdate();
}
@@ -376,6 +370,14 @@ namespace FlaxEditor.Windows.Assets
return false;
}
/// <inheritdoc />
protected override void OnSurfaceEditingStart()
{
_propertiesEditor.Select(_properties);
base.OnSurfaceEditingStart();
}
/// <inheritdoc />
protected override void PerformLayoutBeforeChildren()
{

View File

@@ -229,7 +229,7 @@ namespace FlaxEditor.Windows.Assets
layout.Label("No parameters");
return;
}
if (!materialInstance.IsLoaded || materialInstance.BaseMaterial && !materialInstance.BaseMaterial.IsLoaded)
if (!materialInstance.IsLoaded || (materialInstance.BaseMaterial && !materialInstance.BaseMaterial.IsLoaded))
{
layout.Label("Loading...");
return;
@@ -352,10 +352,9 @@ namespace FlaxEditor.Windows.Assets
};
// Material properties editor
_editor = new CustomEditorPresenter(_undo);
_editor = new CustomEditorPresenter(_undo, "Loading...");
_editor.Panel.Parent = _split.Panel2;
_properties = new PropertiesProxy();
_editor.Select(_properties);
_editor.Modified += OnMaterialPropertyEdited;
// Setup input actions
@@ -479,16 +478,11 @@ namespace FlaxEditor.Windows.Assets
/// <inheritdoc />
public override void Update(float deltaTime)
{
// Check if need to load
if (_isWaitingForLoad && _asset.IsLoaded && (_asset.BaseMaterial == null || _asset.BaseMaterial.IsLoaded))
{
// Clear flag
_isWaitingForLoad = false;
// Init material properties and parameters proxy
_properties.OnLoad(this);
// Setup
_editor.Select(_properties);
ClearEditedFlag();
_undo.Clear();
_editor.BuildLayout();

View File

@@ -222,7 +222,6 @@ namespace FlaxEditor.Windows.Assets
// Asset properties proxy
_properties = new PropertiesProxy();
_propertiesEditor.Select(_properties);
// Surface
_surface = new MaterialSurface(this, Save, _undo)
@@ -324,17 +323,14 @@ namespace FlaxEditor.Windows.Assets
get => _asset.LoadSurface(true);
set
{
// Create material info
FillMaterialInfo(out var info);
// Save data to the temporary material
if (_asset.SaveSurface(value, info))
{
// Error
_surface.MarkAsEdited();
Editor.LogError("Failed to save material surface data");
}
_asset.Reload();
_asset.WaitForLoaded();
}
}
@@ -347,7 +343,6 @@ namespace FlaxEditor.Windows.Assets
// Load surface graph
if (_surface.Load())
{
// Error
Editor.LogError("Failed to load material surface.");
return true;
}
@@ -362,6 +357,14 @@ namespace FlaxEditor.Windows.Assets
return false;
}
/// <inheritdoc />
protected override void OnSurfaceEditingStart()
{
_propertiesEditor.Select(_properties);
base.OnSurfaceEditingStart();
}
/// <inheritdoc />
protected override bool CanEditSurfaceOnAssetLoadError => true;

View File

@@ -120,7 +120,6 @@ namespace FlaxEditor.Windows.Assets
// Asset properties proxy
_properties = new PropertiesProxy();
_propertiesEditor.Select(_properties);
// Preview properties editor
_previewTab = new Tab("Preview");
@@ -217,14 +216,13 @@ namespace FlaxEditor.Windows.Assets
get => _asset.LoadSurface(true);
set
{
// Save data to the temporary asset
if (_asset.SaveSurface(value))
{
// Error
_surface.MarkAsEdited();
Editor.LogError("Failed to save Particle Emitter surface data");
}
_asset.Reload();
_asset.WaitForLoaded();
_preview.PreviewActor.ResetSimulation();
_previewTab.Presenter.BuildLayoutOnUpdate();
}
@@ -255,6 +253,14 @@ namespace FlaxEditor.Windows.Assets
return false;
}
/// <inheritdoc />
protected override void OnSurfaceEditingStart()
{
_propertiesEditor.Select(_properties);
base.OnSurfaceEditingStart();
}
/// <inheritdoc />
protected override bool SaveToOriginal()
{