Table of Contents

Class TMPTextProcessor

Namespace
TMPEffects.TextProcessing
Assembly
TMPEffects.dll

Preprocesses the text, removing valid tags.
As part of a post process, also adjusts the indices of the parsed tags to accomodate for native TextMeshPro tags.

public class TMPTextProcessor : ITextPreprocessor, ITagProcessorManager, IEnumerable<TagProcessor>, IEnumerable
Inheritance
TMPTextProcessor
Implements
ITextPreprocessor
Inherited Members

Constructors

TMPTextProcessor(TMP_Text)

public TMPTextProcessor(TMP_Text text)

Parameters

text TMP_Text

Properties

TagProcessors

Mapping of prefix to list of TagProcessor.

public ReadOnlyDictionary<char, ReadOnlyCollection<TagProcessor>> TagProcessors { get; }

Property Value

ReadOnlyDictionary<char, ReadOnlyCollection<TagProcessor>>

TextComponent

The associated TMPro.TMP_Text component.

public TMP_Text TextComponent { get; }

Property Value

TMP_Text

Methods

AddProcessor(char, TagProcessor, int)

Add a processor.

public void AddProcessor(char prefix, TagProcessor processor, int priority = 0)

Parameters

prefix char

Prefix of tags processed by processor.

processor TagProcessor

The processor.

priority int

Priority of this processor. Only one processors can process any given tag, so the order that processors are invoked in matters.
Less than zero => last processed
zero => first processed (highest priority)
Greater than zero => priority-th processed
Greater than current amount of processors => last processed

AdjustIndices()

Adjust the indices that were cached during the preprocess stage to accomodate for index changes due to native TextMeshPro tags.

public void AdjustIndices()

GetEnumerator()

public IEnumerator<TagProcessor> GetEnumerator()

Returns

IEnumerator<TagProcessor>

PreprocessText(string)

Preprocess the text.

  • Remove TMPEffects tags from text
  • Cache the tags incl. their indices
public string PreprocessText(string text)

Parameters

text string

The text to preprocess.

Returns

string

The preprocessed text.

RemoveProcessor(char, TagProcessor)

Remove a processor.

public bool RemoveProcessor(char prefix, TagProcessor processor)

Parameters

prefix char

Prefix of tags processed by processor.

processor TagProcessor

The processor.

Returns

bool

true if the processors was removed; otherwise false.

Events

BeginAdjustIndices

Raised just before the AdjustIndices routine begins.

public event TMPTextProcessor.TMPTextProcessorEventHandler BeginAdjustIndices

Event Type

TMPTextProcessor.TMPTextProcessorEventHandler

BeginPreProcess

Raised just before the PreProcess routine begins.

public event TMPTextProcessor.TMPTextProcessorEventHandler BeginPreProcess

Event Type

TMPTextProcessor.TMPTextProcessorEventHandler

FinishAdjustIndices

Raised once the AdjustIndices routine finished.

public event TMPTextProcessor.TMPTextProcessorEventHandler FinishAdjustIndices

Event Type

TMPTextProcessor.TMPTextProcessorEventHandler

FinishPreProcess

Raised once the PreProcess routine finished.

public event TMPTextProcessor.TMPTextProcessorEventHandler FinishPreProcess

Event Type

TMPTextProcessor.TMPTextProcessorEventHandler