using System;
using System.Collections;
using System.Collections.Generic;
using JetBrains.Annotations;
using UnityEngine;
namespace Omega.Tools
{
public static class TransformUtility
{
///
/// Возвращает всех потомков указанного трансформа
///
/// Трансформ, относительно которого будет осуществляться поиск потомков
/// Массив потомков
/// Параметр >указывает на null
/// Параметр >указывает на уничтоженный объект
[NotNull]
public static Transform[] GetChildes([NotNull] Transform root)
{
if (ReferenceEquals(root, null))
throw new ArgumentNullException(nameof(root));
if (!root)
throw new MissingReferenceException(nameof(root));
return GetChildesWithoutChecks(root);
}
[NotNull]
internal static Transform[] GetChildesWithoutChecks([NotNull] Transform root)
{
var childesCount = root.childCount;
var childes = childesCount == 0 ? Array.Empty() : new Transform[childesCount];
for (int i = 0; i < childesCount; i++)
childes[i] = root.GetChild(i);
return childes;
}
}
}