Add **Animation Events**

This commit is contained in:
Wojtek Figat
2022-01-08 15:06:02 +01:00
parent 79200a784b
commit 82a43dea28
11 changed files with 720 additions and 3 deletions

View File

@@ -163,6 +163,7 @@ namespace FlaxEditor.Viewport.Previews
: base(useWidgets)
{
Task.Begin += OnBegin;
ScriptsBuilder.ScriptsReloadBegin += OnScriptsReloadBegin;
// Setup preview scene
_previewModel = new AnimatedModel
@@ -275,6 +276,12 @@ namespace FlaxEditor.Viewport.Previews
}
}
private void OnScriptsReloadBegin()
{
// Prevent any crashes due to dangling references to anim events
_previewModel.ResetAnimation();
}
private int ComputeLODIndex(SkinnedModel model)
{
if (PreviewActor.ForcedLOD != -1)
@@ -428,6 +435,7 @@ namespace FlaxEditor.Viewport.Previews
/// <inheritdoc />
public override void OnDestroy()
{
ScriptsBuilder.ScriptsReloadBegin -= OnScriptsReloadBegin;
Object.Destroy(ref _floorModel);
Object.Destroy(ref _previewModel);
NodesMask = null;