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

Starts With#

Strings / Starts With

  • Can Read

  • Cannot Write

Description#

Returns True if a text begins with another one

Parameters#

Name Description
Text The text that is checked
Prefix The text expected at the beginning
Ignore Case Whether upper and lower case characters are considered the same

Code#

using System;
using UnityEngine;
using VisualScript.Icons;

namespace VisualScript.Runtime
{
    [Get]

    [Title("Starts With")]
    [Category("Strings/Starts With")]

    [Description("Returns True if a text begins with another one")]
    [Image(typeof(IconString), ColorTheme.Type.Yellow, typeof(BadgeArrowLeft))]

    [Parameter("Text", "The text that is checked")]
    [Parameter("Prefix", "The text expected at the beginning")]
    [Parameter("Ignore Case", "Whether upper and lower case characters are considered the same")]

    [Keywords("String", "Prefix", "Begins", "Head", "Find")]

    [Serializable]
    public class TypeBoolStringStartsWith : TypeBool
    {
        [SerializeField] private GetString m_Text = new GetString();
        [SerializeField] private GetString m_Prefix = new GetString();
        [SerializeField] private GetBool m_IgnoreCase = new GetBool(false);

        public override bool GetPreview(GameObject source) => StartsWith(
            this.m_Text.GetPreview(source),
            this.m_Prefix.GetPreview(source),
            this.m_IgnoreCase.GetPreview(source)
        );

        public override bool Get(Args args) => StartsWith(
            this.m_Text.Get(args),
            this.m_Prefix.Get(args),
            this.m_IgnoreCase.Get(args)
        );

        private static bool StartsWith(string text, string prefix, bool ignoreCase)
        {
            if (string.IsNullOrEmpty(text) || string.IsNullOrEmpty(prefix)) return false;

            return text.StartsWith(prefix, ignoreCase
                ? StringComparison.OrdinalIgnoreCase
                : StringComparison.Ordinal);
        }

        public override string ToString()
        {
            return $"{this.m_Text} starts with {this.m_Prefix}";
        }

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