Exemplo n.º 1
0
    public static T[] GetComponentsInDirectChildren <T>(this GameObject gameObject, bool searchInRoot)
    {
        if (gameObject is null)
        {
            throw new NullReferenceException(nameof(gameObject));
        }
        if (!gameObject)
        {
            throw new MissingReferenceException(nameof(gameObject));
        }

        var result = ListPool <T> .Rent();

        GameObjectUtilities.GetComponentsDirectWithoutChecks(gameObject, result, searchInRoot);

        var resultArray = result.Count == 0 ? Array.Empty <T>() : result.ToArray();

        ListPool <T> .ReturnInternal(result);

        return(resultArray);
    }