Characters#
Strings / Characters
Can Read
Cannot Write
Description#
The collection made of every single character of a text, in order
Parameters#
| Name | Description |
|---|---|
| Text | The text that is broken into characters |
Code#
using System;
using System.Collections.Generic;
using UnityEngine;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Get]
[Title("Characters")]
[Category("Strings/Characters")]
[Description("The collection made of every single character of a text, in order")]
[Image(typeof(IconString), ColorTheme.Type.Yellow, typeof(BadgeString))]
[Parameter("Text", "The text that is broken into characters")]
[Keywords("String", "Letters", "Char", "Each", "Iterate", "Loop")]
[Serializable]
public class TypeCollectionStringCharacters : TTypeCollection<string>
{
// EXPOSED MEMBERS: -----------------------------------------------------------------------
[SerializeField] private GetString m_Text = new GetString();
// PUBLIC METHODS: ------------------------------------------------------------------------
public override string ToString()
{
return $"Characters of {this.m_Text}";
}
// PROTECTED METHODS: ---------------------------------------------------------------------
protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
protected override void OnCapture(Args args, List<string> items)
{
string text = this.m_Text.Get(args);
if (string.IsNullOrEmpty(text)) return;
foreach (char character in text)
{
items.Add(character.ToString());
}
}
}
}