SbTween/Examples/TextRenderer/Sbe_TextTypewriter.cs

A small example component that runs on start and animates a TextRenderer with a typewriter effect. It reads properties for the TextRenderer, the string to display, and whether to use a cursor, then starts either TypewriterWithCursor or Typewriter with looping YoYo playback.

Networking
using Sandbox;

namespace SbTween.Examples;

public sealed class Sbe_TextTypewriter : Component
{
	[Property] public TextRenderer TR;
	[Property] public string Say;
	[Property] public bool useCursor;


	protected override void OnStart()
	{
		if ( useCursor )
		{

			TR.TypewriterWithCursor( Say, 3, "|" ).SetLoops( -1, LoopType.YoYo ).Play();
		}
		else
		{
			TR.Typewriter( Say, 1 ).SetLoops( -1, LoopType.YoYo ).Play();
		}
	}


}