From 214889470fb344609f6b3b76745b75e2dae07890 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20L=C3=BCbe=C3=9F?= Date: Sat, 18 Nov 2023 02:00:11 +0100 Subject: [PATCH] Scene: Set ScriptEngine Context (Scene) when copying entities Fixes invalid access when constructors throw exceptions --- GlitchyEngine/src/World/Scene.bf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/GlitchyEngine/src/World/Scene.bf b/GlitchyEngine/src/World/Scene.bf index 6ca639c..d677367 100644 --- a/GlitchyEngine/src/World/Scene.bf +++ b/GlitchyEngine/src/World/Scene.bf @@ -133,6 +133,9 @@ namespace GlitchyEngine.World if (initializeScripts) { + // Set context, so that constructors can correctly reference the scene + ScriptEngine.SetContext(target); + //CopyComponents(this, target); // Copy ScriptComponents... needs extra handling for the script instances