diff --git a/Source/Editor/Windows/Assets/AnimationWindow.cs b/Source/Editor/Windows/Assets/AnimationWindow.cs
index 2411daf86..84fedc9f8 100644
--- a/Source/Editor/Windows/Assets/AnimationWindow.cs
+++ b/Source/Editor/Windows/Assets/AnimationWindow.cs
@@ -80,6 +80,7 @@ namespace FlaxEditor.Windows.Assets
private AnimationWindow Window;
private Animation Asset;
private ModelImportSettings ImportSettings = new ModelImportSettings();
+ private bool EnablePreviewModelCache = true;
[EditorDisplay("Preview"), NoSerialize, AssetReference(true), Tooltip("The skinned model to preview the animation playback.")]
public SkinnedModel PreviewModel
@@ -134,6 +135,15 @@ namespace FlaxEditor.Windows.Assets
value.WaitForLoaded(500);
Window._preview.ViewportCamera.SetArcBallView(Window._preview.PreviewActor.Sphere);
}
+
+ if (EnablePreviewModelCache)
+ {
+ var customDataName = Window.GetPreviewModelCacheName();
+ if (value)
+ Window.Editor.ProjectCache.SetCustomData(customDataName, value.ID.ToString());
+ else
+ Window.Editor.ProjectCache.RemoveCustomData(customDataName);
+ }
}
}
@@ -142,6 +152,7 @@ namespace FlaxEditor.Windows.Assets
// Link
Window = window;
Asset = window.Asset;
+ EnablePreviewModelCache = true;
// Try to restore target asset import options (useful for fast reimport)
Editor.TryRestoreImportOptions(ref ImportSettings.Settings, window.Item.Path);
@@ -150,6 +161,7 @@ namespace FlaxEditor.Windows.Assets
public void OnClean()
{
// Unlink
+ EnablePreviewModelCache = false;
PreviewModel = null;
Window = null;
Asset = null;
@@ -287,12 +299,23 @@ namespace FlaxEditor.Windows.Assets
UpdateToolstrip();
}
+ private string GetPreviewModelCacheName()
+ {
+ return _asset.ID + ".PreviewModel";
+ }
+
///
protected override void OnAssetLoaded()
{
_properties.OnLoad(this);
_propertiesPresenter.BuildLayout();
ClearEditedFlag();
+ if (!_initialPreviewModel &&
+ Editor.ProjectCache.TryGetCustomData(GetPreviewModelCacheName(), out string str) &&
+ Guid.TryParse(str, out var id))
+ {
+ _initialPreviewModel = FlaxEngine.Content.LoadAsync(id);
+ }
if (_initialPreviewModel)
{
_properties.PreviewModel = _initialPreviewModel;