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

Maximum#

Collections / Maximum

  • Can Read

  • Cannot Write

Description#

The largest value found in a collection read as numbers

Parameters#

Name Description
Collection The collection whose largest item is returned

Code#

using System;
using UnityEngine;
using VisualScript.Icons;

namespace VisualScript.Runtime
{
    [Get]

    [Title("Maximum")]
    [Category("Collections/Maximum")]

    [Description("The largest value found in a collection read as numbers")]
    [Image(typeof(IconStack), ColorTheme.Type.Teal, typeof(BadgeArrowUp))]

    [Parameter("Collection", "The collection whose largest item is returned")]

    [Keywords("Max", "Highest", "Biggest", "Greatest", "List", "Array")]

    [Serializable]
    public class TypeNumberCollectionMax : TypeNumber
    {
        [SerializeField] private GetCollection m_Collection = new GetCollection();

        public override double Get(Args args)
        {
            using Args scoped = Args.Get(args);

            int count = this.m_Collection.Capture(scoped);
            if (count == 0) return 0f;

            double max = 0f;
            bool hasValue = false;

            for (int i = 0; i < count; ++i)
            {
                if (!ArgsCollectionParameters.TryGetItem(this.m_Collection, scoped, i, out double item)) continue;

                max = hasValue ? Math.Max(max, item) : item;
                hasValue = true;
            }

            return max;
        }

        public override string ToString()
        {
            return $"Max of {this.m_Collection}";
        }

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