| | 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 | |
|
| | 5 | | #if !UNITY_DOTSRUNTIME |
| | 6 | |
|
| | 7 | | using System.Diagnostics.CodeAnalysis; |
| | 8 | | using System.Runtime.CompilerServices; |
| | 9 | | using UnityEngine; |
| | 10 | |
|
| | 11 | | namespace GDX |
| | 12 | | { |
| | 13 | | /// <summary> |
| | 14 | | /// <see cref="UnityEngine.GameObject" /> Based Extension Methods |
| | 15 | | /// </summary> |
| | 16 | | /// <exception cref="UnsupportedRuntimeException">Not supported on DOTS Runtime.</exception> |
| | 17 | | [VisualScriptingCompatible(2)] |
| | 18 | | public static class GameObjectExtensions |
| | 19 | | { |
| | 20 | | /// <summary> |
| | 21 | | /// Destroy child <see cref="GameObject" />. |
| | 22 | | /// </summary> |
| | 23 | | /// <param name="targetGameObject">The parent <see cref="GameObject" /> to look at.</param> |
| | 24 | | /// <param name="deactivateBeforeDestroy"> |
| | 25 | | /// Should the <paramref name="targetGameObject" />'s children be deactivated before |
| | 26 | | /// destroying? This can be used to immediately hide an object, that will be destroyed at the end of the fra |
| | 27 | | /// </param> |
| | 28 | | /// <param name="destroyInactive">Should inactive <see cref="GameObject" /> be destroyed as well?</param> |
| | 29 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 30 | | [ExcludeFromCodeCoverage] |
| | 31 | | public static void DestroyChildren(this GameObject targetGameObject, bool deactivateBeforeDestroy = true, |
| | 32 | | bool destroyInactive = true) |
| | 33 | | { |
| | 34 | | targetGameObject.transform.DestroyChildren(deactivateBeforeDestroy, destroyInactive); |
| | 35 | | } |
| | 36 | |
|
| | 37 | | /// <summary> |
| | 38 | | /// A slightly more complex version of <see cref="Component.GetComponentInChildren{T}(bool)" /> which allows |
| | 39 | | /// different hinted search options. |
| | 40 | | /// </summary> |
| | 41 | | /// <remarks> |
|