Documentation index for AI agents (llms.txt) A Markdown version of every page is available: request the page's source under /docs/, follow the "alternate" link in this page's head, or start from /llms.txt.
Visual Script logo Manual

Collection Contains Game Object#

Collections / Collection Contains Game Object

  • Can Read

  • Cannot Write

Description#

Returns True if the collection has the specified Game Object among its items

Parameters#

Name Description
Collection The collection whose items are searched
Game Object The Game Object reference searched for

Code#

using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Pool;
using VisualScript.Icons;

namespace VisualScript.Runtime
{
    [Get]

    [Title("Collection Contains Game Object")]
    [Category("Collections/Contains Game Object")]

    [Description("Returns True if the collection has the specified Game Object among its items")]
    [Image(typeof(IconStack), ColorTheme.Type.Teal, typeof(BadgeCubeOutline))]

    [Parameter("Collection", "The collection whose items are searched")]
    [Parameter("Game Object", "The Game Object reference searched for")]

    [Keywords("Has", "Includes", "Find", "Search", "Any", "List", "Array")]

    [Serializable]
    public class TypeBoolCollectionContainsGameObject : TypeBool
    {
        [SerializeField] private GetCollectionGameObjects m_Collection = new GetCollectionGameObjects();
        [SerializeField] private GetGameObject m_GameObject = new GetGameObject();

        public override bool Get(Args args)
        {
            GameObject gameObject = this.m_GameObject.Get(args);
            if (gameObject == null) return false;

            List<GameObject> buffer = ListPool<GameObject>.Get();

            try
            {
                this.m_Collection.Get(args, buffer);

                bool contains = buffer.Contains(gameObject);

                return contains;
            }
            finally
            {
                ListPool<GameObject>.Release(buffer);
            }
        }

        public override string ToString()
        {
            return $"{this.m_Collection} contains {this.m_GameObject}";
        }

        protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
    }
}
Visual Script logoVisual Script © Catsoft Works 2026. All rights reserved.