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
Processor
The TMPTextProcessor used by the associated TMPro.TMP_Text component.
public readonly TMPTextProcessor Processor
Field Value
Text
The associated TMPro.TMP_Text component.
public readonly TMP_Text Text
Field Value
- TMP_Text
VisibilityStates
public readonly ReadOnlyCollection<VisibilityState> VisibilityStates
Field Value
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
CharDataThe 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
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
objectThe 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
intThe first index of the to-be-updated VisibilityState.
length
intThe amount of to-be-updated VisibilityState.
state
VisibilityStateThe VisibilityState to set to.
Exceptions
SetVisibilityState(int, VisibilityState)
Set the VisibilityState associated with the CharData at the given index.
public void SetVisibilityState(int index, VisibilityState state)
Parameters
index
intThe index of the to-be-updated VisibilityState.
state
VisibilityStateThe VisibilityState to set to.
Exceptions
SetVisibilityState(CharData, VisibilityState)
Set the VisibilityState associated with the given CharData.
public void SetVisibilityState(CharData cData, VisibilityState state)
Parameters
cData
CharDataThe CharData to set the associated VisibilityState of.
state
VisibilityStateThe 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
UnregisterVisibilityProcessor(object)
Unregister as the visibility processor of this TMPMediator.
public bool UnregisterVisibilityProcessor(object obj)
Parameters
obj
objectThe 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
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
VisibilityStateUpdated
Raised when the VisibilityState of one of the contained CharData is updated.
public event TMPMediator.VisibilityEventHandler VisibilityStateUpdated