コード例 #1
0
        public void Insert([NotNull] GameObject gameObject, bool recursive, bool includeInactive, bool reverse)
        {
            if (gameObject == null)
            {
                throw new ArgumentNullException(nameof(gameObject));
            }

            GetComponentUtilities.GetComponents(gameObject, Type, false, recursive, includeInactive, reverse,
                                                _buffer);


            var bufferCount      = _buffer.Count;
            var requiredCapacity = _iterator.Count + bufferCount;

            if (_iterator.Capacity < requiredCapacity)
            {
                _iterator.Capacity = requiredCapacity;
            }

            for (int i = 0; i < bufferCount; i++)
            {
                var item = _buffer[i];
                if (item != null)
                {
                    _iterator.Add(item);
                }
            }
        }
コード例 #2
0
        public Enumerator(GameObject gameObject, bool recursive, bool includeInactive, bool reverse)
        {
            if (gameObject == null)
            {
                throw new ArgumentNullException(nameof(gameObject));
            }

            _internalList = ObjectListPool.Rent();
            GetComponentUtilities.GetComponents(gameObject, Type, false, recursive, includeInactive, reverse, _internalList);
            _index = -1;
        }
コード例 #3
0
    public static void SetComponentsInChildrenEnabledState <T>(this GameObject gameObject, bool enabled, bool includeInactive = true) where T : Behaviour
    {
        var internalList = ObjectListPool.Rent();

        GetComponentUtilities.GetComponents(gameObject, typeof(T), false, true, includeInactive, false, internalList);

        var count = internalList.Count;

        for (int i = 0; i < count; i++)
        {
            var behaviour = Unsafe.As <T>(internalList[i]);
            behaviour.enabled = enabled;
        }

        ObjectListPool.Return(internalList);
    }