From 803fd7f8ba8abcb23136d9bef4ff5a84a11891b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20L=C3=BCbe=C3=9F?= Date: Mon, 31 Jul 2023 16:36:02 +0200 Subject: [PATCH] Fixed crash when ScriptComponent has no Instance in Play Mode --- GlitchyEngine/src/World/Scene.bf | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/GlitchyEngine/src/World/Scene.bf b/GlitchyEngine/src/World/Scene.bf index a2e2feb..4fcf308 100644 --- a/GlitchyEngine/src/World/Scene.bf +++ b/GlitchyEngine/src/World/Scene.bf @@ -106,7 +106,9 @@ namespace GlitchyEngine.World for (let (handle, script) in target._ecsWorld.Enumerate()) { Entity entity = .(handle, this); - ScriptEngine.CopyEditorFieldsToInstance(entity, script); + + if (script.Instance != null) + ScriptEngine.CopyEditorFieldsToInstance(entity, script); } // Copy transforms... needs special handling for the Parent<->Child relations @@ -284,6 +286,9 @@ namespace GlitchyEngine.World if (!script.IsInitialized) ScriptEngine.InitializeInstance(Entity(entity, this), script); + if (script.Instance == null) + continue; + if (mode.HasFlag(.Runtime)) script.Instance.InvokeOnCreate(); }