Fix missing asset update when dependant asset gets saved in Editor

#1489
This commit is contained in:
Wojtek Figat
2023-12-27 20:57:37 +01:00
parent 4d9ef32abc
commit 4a8c94e9d4
2 changed files with 11 additions and 2 deletions

View File

@@ -150,9 +150,7 @@ void BinaryAsset::ClearDependencies()
{
auto asset = Cast<BinaryAsset>(Content::GetAsset(e.First));
if (asset)
{
asset->_dependantAssets.Remove(this);
}
}
Dependencies.Clear();
}
@@ -387,6 +385,16 @@ bool BinaryAsset::SaveToAsset(const StringView& path, AssetInitData& data, bool
if (binaryAsset)
binaryAsset->_isSaving = false;
if (binaryAsset)
{
// Inform dependant asset (use cloned version because it might be modified by assets when they got reloaded)
auto dependantAssets = binaryAsset->_dependantAssets;
for (auto& e : dependantAssets)
{
e->OnDependencyModified(binaryAsset);
}
}
return result;
}

View File

@@ -963,6 +963,7 @@ bool FlaxStorage::Create(WriteStream* stream, const AssetInitData* data, int32 d
// Asset Dependencies
stream->WriteInt32(header.Dependencies.Count());
stream->WriteBytes(header.Dependencies.Get(), header.Dependencies.Count() * sizeof(Pair<Guid, DateTime>));
static_assert(sizeof(Pair<Guid, DateTime>) == sizeof(Guid) + sizeof(DateTime), "Invalid data size.");
}
#if ASSETS_LOADING_EXTRA_VERIFICATION