From fac7c8aa6a1a677f97071061bb27d1a13dad3c49 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sat, 20 Mar 2021 17:56:55 +0100 Subject: [PATCH] Fix possible exception in actor editor bounds getters #286 --- Source/Editor/Editor.cs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/Source/Editor/Editor.cs b/Source/Editor/Editor.cs index ce8805af0..5cada5d87 100644 --- a/Source/Editor/Editor.cs +++ b/Source/Editor/Editor.cs @@ -816,9 +816,16 @@ namespace FlaxEditor /// The bounding sphere. public static void GetActorEditorSphere(Actor actor, out BoundingSphere sphere) { - Internal_GetEditorBoxWithChildren(FlaxEngine.Object.GetUnmanagedPtr(actor), out var box); - BoundingSphere.FromBox(ref box, out sphere); - sphere.Radius = Math.Max(sphere.Radius, 15.0f); + if (actor) + { + Internal_GetEditorBoxWithChildren(FlaxEngine.Object.GetUnmanagedPtr(actor), out var box); + BoundingSphere.FromBox(ref box, out sphere); + sphere.Radius = Math.Max(sphere.Radius, 15.0f); + } + else + { + sphere = BoundingSphere.Empty; + } } /// @@ -828,7 +835,14 @@ namespace FlaxEditor /// The bounding box. public static void GetActorEditorBox(Actor actor, out BoundingBox box) { - Internal_GetEditorBoxWithChildren(FlaxEngine.Object.GetUnmanagedPtr(actor), out box); + if (actor) + { + Internal_GetEditorBoxWithChildren(FlaxEngine.Object.GetUnmanagedPtr(actor), out box); + } + else + { + box = BoundingBox.Zero; + } } ///