From 7046d8b5cd15a25049a8e40188f4755c9033308a Mon Sep 17 00:00:00 2001 From: originalnicodr Date: Fri, 8 Mar 2024 20:38:46 -0300 Subject: [PATCH] Added checks to avoid interacting with some panel cells related to already deleted objects. --- src/UI/Panels/AnimatorPanel.cs | 1 + src/UI/Panels/LightsManger.cs | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/UI/Panels/AnimatorPanel.cs b/src/UI/Panels/AnimatorPanel.cs index b200e8b..bfa13b9 100644 --- a/src/UI/Panels/AnimatorPanel.cs +++ b/src/UI/Panels/AnimatorPanel.cs @@ -146,6 +146,7 @@ namespace UnityExplorer.UI.Panels string check = animatorPlayer.animator.name; } catch { + FindAllAnimators(); return; } diff --git a/src/UI/Panels/LightsManger.cs b/src/UI/Panels/LightsManger.cs index 02810d9..522360c 100644 --- a/src/UI/Panels/LightsManger.cs +++ b/src/UI/Panels/LightsManger.cs @@ -66,6 +66,18 @@ namespace UnityExplorer.UI.Panels } GameObject light = CreatedLights[index]; + + // Check if the light was deleted because we switched scenes, and delete it from the list if that's the case + try { + string check = light.name; + } + catch { + ExplorerCore.LogWarning("Light was deleted by the game!"); + CreatedLights.RemoveAt(index); + lightsScrollPool.Refresh(true, false); + return; + } + cell.light = light; cell.label.text = light.name; } @@ -132,7 +144,7 @@ namespace UnityExplorer.UI.Panels private void CreateLight(LightType requestedType){ GameObject obj = new($"CUE - Light {lightCounter}"); - //DontDestroyOnLoad(obj); + GameObject.DontDestroyOnLoad(obj); obj.hideFlags = HideFlags.HideAndDontSave; Light lightComponent = obj.AddComponent(); lightComponent.type = requestedType;