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
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
charPrefix of tags processed by
processor
.processor
TagProcessorThe processor.
priority
intPriority 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
PreprocessText(string)
Preprocess the text.
- Remove TMPEffects tags from text
- Cache the tags incl. their indices
public string PreprocessText(string text)
Parameters
text
stringThe text to preprocess.
Returns
- string
The preprocessed text.
RemoveProcessor(char, TagProcessor)
Remove a processor.
public bool RemoveProcessor(char prefix, TagProcessor processor)
Parameters
prefix
charPrefix of tags processed by
processor
.processor
TagProcessorThe 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
BeginPreProcess
Raised just before the PreProcess routine begins.
public event TMPTextProcessor.TMPTextProcessorEventHandler BeginPreProcess
Event Type
FinishAdjustIndices
Raised once the AdjustIndices routine finished.
public event TMPTextProcessor.TMPTextProcessorEventHandler FinishAdjustIndices
Event Type
FinishPreProcess
Raised once the PreProcess routine finished.
public event TMPTextProcessor.TMPTextProcessorEventHandler FinishPreProcess