diff --git a/Source/Engine/AI/BehaviorTree.cpp b/Source/Engine/AI/BehaviorTree.cpp index 653e44335..acc089036 100644 --- a/Source/Engine/AI/BehaviorTree.cpp +++ b/Source/Engine/AI/BehaviorTree.cpp @@ -5,6 +5,7 @@ #include "BehaviorTreeNodes.h" #include "Engine/Core/Collections/Sorting.h" #include "Engine/Content/Factories/BinaryAssetFactory.h" +#include "Engine/Content/JsonAsset.h" #include "Engine/Scripting/Scripting.h" #include "Engine/Serialization/JsonSerializer.h" #include "Engine/Serialization/MemoryReadStream.h" @@ -174,6 +175,24 @@ bool BehaviorTree::SaveSurface(const BytesContainer& data) return false; } +void BehaviorTree::GetReferences(Array& output) const +{ + // Base + BinaryAsset::GetReferences(output); + + Graph.GetReferences(output); + + // Extract refs from serialized nodes data + for (const BehaviorTreeGraphNode& n : Graph.Nodes) + { + if (n.Instance == nullptr) + continue; + const Variant& data = n.Values[1]; + if (data.Type == VariantType::Blob) + JsonAssetBase::GetReferences(StringAnsiView((char*)data.AsBlob.Data, data.AsBlob.Length), output); + } +} + #endif Asset::LoadResult BehaviorTree::load() diff --git a/Source/Engine/AI/BehaviorTree.h b/Source/Engine/AI/BehaviorTree.h index f81228162..0888be64d 100644 --- a/Source/Engine/AI/BehaviorTree.h +++ b/Source/Engine/AI/BehaviorTree.h @@ -82,13 +82,7 @@ public: public: // [BinaryAsset] #if USE_EDITOR - void GetReferences(Array& output) const override - { - // Base - BinaryAsset::GetReferences(output); - - Graph.GetReferences(output); - } + void GetReferences(Array& output) const override; #endif protected: