diff --git a/Source/Engine/Content/Assets/Animation.cpp b/Source/Engine/Content/Assets/Animation.cpp index 917db28ac..86fa41f89 100644 --- a/Source/Engine/Content/Assets/Animation.cpp +++ b/Source/Engine/Content/Assets/Animation.cpp @@ -691,11 +691,7 @@ Asset::LoadResult Animation::load() continue; } #if USE_EDITOR - if (!_registeredForScriptingReload) - { - _registeredForScriptingReload = true; - Level::ScriptsReloadStart.Bind(this); - } + _registerForScriptingReload = true; #endif } } @@ -733,6 +729,7 @@ void Animation::unload(bool isReloading) { ScopeWriteLock systemScope(Animations::SystemLocker); #if USE_EDITOR + _registerForScriptingReload = false; if (_registeredForScriptingReload) { _registeredForScriptingReload = false; @@ -752,6 +749,22 @@ void Animation::unload(bool isReloading) NestedAnims.Clear(); } +#if USE_EDITOR + +void Animation::onLoaded_MainThread() +{ + if (_registerForScriptingReload && !_registeredForScriptingReload) + { + _registeredForScriptingReload = true; + Level::ScriptsReloadStart.Bind(this); + } + _registerForScriptingReload = false; + + BinaryAsset::onLoaded_MainThread(); +} + +#endif + AssetChunksFlag Animation::getChunksToPreload() const { return GET_CHUNK_FLAG(0); diff --git a/Source/Engine/Content/Assets/Animation.h b/Source/Engine/Content/Assets/Animation.h index 4f4a773b4..c342cc64c 100644 --- a/Source/Engine/Content/Assets/Animation.h +++ b/Source/Engine/Content/Assets/Animation.h @@ -78,6 +78,7 @@ API_CLASS(NoSpawn) class FLAXENGINE_API Animation : public BinaryAsset private: #if USE_EDITOR + bool _registerForScriptingReload = false; bool _registeredForScriptingReload = false; void OnScriptsReloadStart(); #endif @@ -163,5 +164,8 @@ protected: // [BinaryAsset] LoadResult load() override; void unload(bool isReloading) override; +#if USE_EDITOR + void onLoaded_MainThread() override; +#endif AssetChunksFlag getChunksToPreload() const override; };