< Summary

Class:GDX.ObjectExtensions
Assembly:GDX
File(s):./Packages/com.dotbunny.gdx/GDX/ObjectExtensions.cs
Covered lines:0
Uncovered lines:9
Coverable lines:9
Total lines:38
Line coverage:0% (0 of 9)
Covered branches:0
Total branches:0
Covered methods:0
Total methods:1
Method coverage:0% (0 of 1)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SafeDestroy(...)0%6200%

File(s)

./Packages/com.dotbunny.gdx/GDX/ObjectExtensions.cs

#LineLine coverage
 1// Copyright (c) 2020-2024 dotBunny Inc.
 2// dotBunny licenses this file to you under the BSL-1.0 license.
 3// See the LICENSE file in the project root for more information.
 4
 5using System.Runtime.CompilerServices;
 6using UnityEngine;
 7
 8namespace GDX
 9{
 10    /// <summary>
 11    ///     <see cref="UnityEngine.Object" /> Based Extension Methods
 12    /// </summary>
 13    [VisualScriptingCompatible(2)]
 14    public static class ObjectExtensions
 15    {
 16        /// <summary>
 17        ///     Destroy a <see cref="UnityEngine.Object" /> appropriately based on the current state of the Editor/Playe
 18        /// </summary>
 19        /// <param name="targetObject">The target <see cref="UnityEngine.Object" /> to be destroyed.</param>
 20        /// <param name="delay">How long should be waited before the <paramref name="targetObject" /> is destroyed?</par
 21        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 22        public static void SafeDestroy(this Object targetObject, float delay = 0f)
 023        {
 24#if UNITY_EDITOR
 025            if (Application.isPlaying)
 026            {
 027                Object.Destroy(targetObject, delay);
 028            }
 29            else
 030            {
 031                Object.DestroyImmediate(targetObject);
 032            }
 33#else
 34            Object.Destroy(targetObject, delay);
 35#endif // UNITY_EDITOR
 036        }
 37    }
 38}