Table of Contents

Class TMPMediator

Namespace
TMPEffects.Components.Mediator
Assembly
TMPEffects.dll

A mediator class for TMPAnimator and TMPWriter (and potential additions, if any).
Handles the pre- and postprocessing of the text, as well as maintaining information about it in the form of a CharData and VisibilityState collection.

public class TMPMediator : IDisposable
Inheritance
TMPMediator
Implements
Inherited Members

Fields

CharData

public readonly ReadOnlyCollection<CharData> CharData

Field Value

ReadOnlyCollection<CharData>

Processor

The TMPTextProcessor used by the associated TMPro.TMP_Text component.

public readonly TMPTextProcessor Processor

Field Value

TMPTextProcessor

Text

The associated TMPro.TMP_Text component.

public readonly TMP_Text Text

Field Value

TMP_Text

VisibilityStates

public readonly ReadOnlyCollection<VisibilityState> VisibilityStates

Field Value

ReadOnlyCollection<VisibilityState>

Methods

ApplyMesh(CharData)

Apply the mesh of the CharData.

public void ApplyMesh(CharData cData)

Parameters

cData CharData

Dispose()

Dispose the TMPMediator instance.

public void Dispose()

ForceReprocess()

Forces a mesh update on the associated TMPro.TMP_Text component.
Will reprocess the text.

public void ForceReprocess()

GetVisibilityState(CharData)

Get the associated VisibilityState of the given CharData.

public VisibilityState GetVisibilityState(CharData cData)

Parameters

cData CharData

The CharData to get the VisibilityState of.

Returns

VisibilityState

The associated VisibilityState of the given CharData.

Remarks

This uses the index property of info to get the associated VisibilityState.
Therefore, the responsiblity is on you to ensure cData is valid, i.e. belongs to this TMPMediator instance.

Exceptions

ArgumentOutOfRangeException
NullReferenceException

RegisterVisibilityProcessor(object)

Register as the visibility processor of this TMPMediator.
There may be at most one visibility processor registered at any given time.
This makes you responsible of applying any actual changes to the mesh of the character when its associated VisibilityState is updated.
Subscribe to the VisibilityStateUpdated event to get a callback whenever an VisibilityState is updated.

public bool RegisterVisibilityProcessor(object obj)

Parameters

obj object

The object to identify the subscriber.

Returns

bool

true if registration was successful; otherwise false.

SetText(string)

Set the text of the associated TMPro.TMP_Text component.

public void SetText(string text)

Parameters

text string

SetVisibilityState(int, int, VisibilityState)

Set the VisibilityState associated with the CharData at the given indices.

public void SetVisibilityState(int startIndex, int length, VisibilityState state)

Parameters

startIndex int

The first index of the to-be-updated VisibilityState.

length int

The amount of to-be-updated VisibilityState.

state VisibilityState

The VisibilityState to set to.

Exceptions

ArgumentOutOfRangeException

SetVisibilityState(int, VisibilityState)

Set the VisibilityState associated with the CharData at the given index.

public void SetVisibilityState(int index, VisibilityState state)

Parameters

index int

The index of the to-be-updated VisibilityState.

state VisibilityState

The VisibilityState to set to.

Exceptions

ArgumentOutOfRangeException

SetVisibilityState(CharData, VisibilityState)

Set the VisibilityState associated with the given CharData.

public void SetVisibilityState(CharData cData, VisibilityState state)

Parameters

cData CharData

The CharData to set the associated VisibilityState of.

state VisibilityState

The VisibilityState to set to.

Remarks

This uses the index property of info to get the associated VisibilityState.
Therefore, the responsiblity is on you to ensure cData is valid, i.e. belongs to this TMPMediator instance.

Exceptions

ArgumentOutOfRangeException

UnregisterVisibilityProcessor(object)

Unregister as the visibility processor of this TMPMediator.

public bool UnregisterVisibilityProcessor(object obj)

Parameters

obj object

The object to identify the subscriber.

Returns

bool

true if registration was successful; otherwise false.

Events

TextChanged_Early

Raised when the associated TMPro.TMP_Text component raises its TEXT_CHANGED_EVENT, before TextChanged_Late.
You should use this callback for initialization, e.g. processing tags. Don't modify data that might mess with the initialization of other listeners, such as setting visibilities or char data. For such operations, use TextChanged_Late.

public event TMPMediator.TextChangedEarlyEventHandler TextChanged_Early

Event Type

TMPMediator.TextChangedEarlyEventHandler

TextChanged_Late

Raised when the associated TMPro.TMP_Text component raises its TEXT_CHANGED_EVENT, after TextChanged_Early.

public event TMPMediator.TextChangedLateEventHandler TextChanged_Late

Event Type

TMPMediator.TextChangedLateEventHandler

VisibilityStateUpdated

Raised when the VisibilityState of one of the contained CharData is updated.

public event TMPMediator.VisibilityEventHandler VisibilityStateUpdated

Event Type

TMPMediator.VisibilityEventHandler