From 057a04fa2ee1e1277457698889fceadd41869ac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Farias?= Date: Thu, 9 Mar 2023 18:33:16 +0000 Subject: [PATCH] Fixed blocks not being destroyed on new/load program --- Assets/Scripts/ModuleManager.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Assets/Scripts/ModuleManager.cs b/Assets/Scripts/ModuleManager.cs index f29317e..11d04d8 100644 --- a/Assets/Scripts/ModuleManager.cs +++ b/Assets/Scripts/ModuleManager.cs @@ -33,6 +33,12 @@ public void Reset() Modules.Clear(); ActiveModule = null; _nodesToModules.Clear(); + + // The game only destroys active gameobjects. We need to destroy the inactive ones ourselves + foreach (BlockElementScript block in _vizzyController.ProgramTransform.GetComponentsInChildren(true)) + { + block.Destroy(); + } } public bool CanRenderNode(ProgramNode node)