< Summary

Class:GDX.MonoBehaviourExtensions
Assembly:GDX
File(s):D:/BuildAgent/work/GDX-Documentation/Projects/GDX_Development/Packages/com.dotbunny.gdx/GDX/MonoBehaviourExtensions.cs
Covered lines:0
Uncovered lines:3
Coverable lines:3
Total lines:57
Line coverage:0% (0 of 3)
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
GetFirstComponentInChildrenComplex[T](...)0%2100%

File(s)

D:/BuildAgent/work/GDX-Documentation/Projects/GDX_Development/Packages/com.dotbunny.gdx/GDX/MonoBehaviourExtensions.cs

#LineLine coverage
 1// Copyright (c) 2020-2022 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
 5#if !UNITY_DOTSRUNTIME
 6
 7using System.Runtime.CompilerServices;
 8using UnityEngine;
 9
 10namespace GDX
 11{
 12    /// <summary>
 13    ///     <see cref="UnityEngine.MonoBehaviour" /> Based Extension Methods
 14    /// </summary>
 15    /// <exception cref="UnsupportedRuntimeException">Not supported on DOTS Runtime.</exception>
 16    [VisualScriptingCompatible(2)]
 17    public static class MonoBehaviourExtensions
 18    {
 19        /// <summary>
 20        ///     A slightly more complex version of <see cref="Component.GetComponentInChildren{T}(bool)" /> which allows
 21        ///     different hinted search options.
 22        /// </summary>
 23        /// <remarks>
 24        ///     <para>
 25        ///         If the <paramref name="maxLevelsOfRecursion" /> is set to 1; this will search the
 26        ///         <paramref name="targetMonoBehaviour" /> and its immediate children only.
 27        ///     </para>
 28        ///     <para>
 29        ///         The internal <see cref="Component.GetComponentInChildren{T}(bool)" /> has optimizations internally i
 30        ///         code which make it faster in different scenarios.
 31        ///     </para>
 32        /// </remarks>
 33        /// <typeparam name="T">The target <see cref="UnityEngine.Component" /> type that is being looked for.</typepara
 34        /// <param name="targetMonoBehaviour">The target <see cref="MonoBehaviour" /> to use as the base for the search.
 35        /// <param name="lookInChildrenFirst">
 36        ///     Should children <see cref="GameObject" /> be searched before the
 37        ///     <paramref name="targetMonoBehaviour" />'s <see cref="GameObject" />.
 38        /// </param>
 39        /// <param name="includeInactive">
 40        ///     Include inactive child <see cref="GameObject" />s when looking for the
 41        ///     <see cref="Component" />.
 42        /// </param>
 43        /// <param name="maxLevelsOfRecursion">
 44        ///     The maximum levels of recursion when looking for a <see cref="Component" />, -1 for
 45        ///     infinite recursion.
 46        /// </param>
 47        /// <returns>The first found <see cref="Component" />.</returns>
 48        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 49        public static T GetFirstComponentInChildrenComplex<T>(this MonoBehaviour targetMonoBehaviour,
 50            bool includeInactive = false, bool lookInChildrenFirst = false, int maxLevelsOfRecursion = -1)
 051        {
 052            return targetMonoBehaviour.gameObject.GetFirstComponentInChildrenComplex<T>(includeInactive,
 53                lookInChildrenFirst, maxLevelsOfRecursion);
 054        }
 55    }
 56}
 57#endif