Add content deprecation system that auto-saves assets in Editor that use old data format

This commit is contained in:
Wojtek Figat
2025-01-20 23:46:49 +01:00
parent 1497acef58
commit 8a7ceef288
67 changed files with 751 additions and 427 deletions

View File

@@ -13,6 +13,7 @@
#include "FlaxEngine.Gen.h"
#if USE_EDITOR
#include "Engine/Level/Level.h"
#include "Engine/Serialization/MemoryWriteStream.h"
#endif
REGISTER_BINARY_ASSET(BehaviorTree, "FlaxEngine.BehaviorTree", false);
@@ -164,7 +165,7 @@ BehaviorTreeNode* BehaviorTree::GetNodeInstance(uint32 id)
return nullptr;
}
BytesContainer BehaviorTree::LoadSurface()
BytesContainer BehaviorTree::LoadSurface() const
{
if (WaitForLoaded())
return BytesContainer();
@@ -182,19 +183,10 @@ BytesContainer BehaviorTree::LoadSurface()
#if USE_EDITOR
bool BehaviorTree::SaveSurface(const BytesContainer& data)
bool BehaviorTree::SaveSurface(const BytesContainer& data) const
{
// Wait for asset to be loaded or don't if last load failed
if (LastLoadFailed())
{
LOG(Warning, "Saving asset that failed to load.");
}
else if (WaitForLoaded())
{
LOG(Error, "Asset loading failed. Cannot save it.");
if (OnCheckSave())
return true;
}
ScopeLock lock(Locker);
// Set Visject Surface data
@@ -250,6 +242,19 @@ void BehaviorTree::GetReferences(Array<Guid>& assets, Array<String>& files) cons
}
}
bool BehaviorTree::Save(const StringView& path)
{
if (OnCheckSave(path))
return true;
ScopeLock lock(Locker);
MemoryWriteStream stream;
if (Graph.Save(&stream, true))
return true;
BytesContainer data;
data.Link(ToSpan(stream));
return SaveSurface(data);
}
#endif
void BehaviorTree::OnScriptingDispose()