Length#
Strings / Length
Can Read
Cannot Write
Description#
The amount of characters a text has
Parameters#
| Name | Description |
|---|---|
| Text | The text whose characters are counted |
Code#
using System;
using UnityEngine;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Get]
[Title("Length")]
[Category("Strings/Length")]
[Description("The amount of characters a text has")]
[Image(typeof(IconString), ColorTheme.Type.Yellow, typeof(BadgeHash))]
[Parameter("Text", "The text whose characters are counted")]
[Keywords("String", "Count", "Size", "Characters", "Amount")]
[Serializable]
public class TypeNumberStringLength : TypeNumber
{
[SerializeField] private GetString m_Text = new GetString();
public override double GetPreview(GameObject source) => this.m_Text.GetPreview(source)?.Length ?? 0;
public override double Get(Args args)
{
return this.m_Text.Get(args)?.Length ?? 0;
}
public override string ToString()
{
return $"Length of {this.m_Text}";
}
protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
}
}