From 470c108ed9cea1194f0f122abc86e177bf3ed658 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Mon, 26 Feb 2024 21:58:31 +0100 Subject: [PATCH] Fix bug with saving Missing Script into file #1995 --- Source/Engine/Level/SceneQuery.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Source/Engine/Level/SceneQuery.cpp b/Source/Engine/Level/SceneQuery.cpp index cbf52e6a2..6a408154d 100644 --- a/Source/Engine/Level/SceneQuery.cpp +++ b/Source/Engine/Level/SceneQuery.cpp @@ -3,6 +3,7 @@ #include "SceneQuery.h" #include "Engine/Scripting/Script.h" #include "Engine/Profiler/Profiler.h" +#include "Scripts/MissingScript.h" Actor* SceneQuery::RaycastScene(const Ray& ray) { @@ -51,6 +52,15 @@ bool GetAllSerializableSceneObjectsQuery(Actor* actor, Array& obje return false; objects.Add(actor); objects.Add(reinterpret_cast(actor->Scripts.Get()), actor->Scripts.Count()); +#if USE_EDITOR + // Skip saving Missing Script instances + for (int32 i = 0; i < actor->Scripts.Count(); i++) + { + const int32 idx = objects.Count() - i - 1; + if (objects.Get()[idx]->GetTypeHandle() == MissingScript::TypeInitializer) + objects.RemoveAtKeepOrder(idx); + } +#endif return true; }