Class TAnimPlayerBase
Base class for all TextAnimatorPlayers (typewriters).
- Manual: TextAnimatorPlayers.
Inheritance
Namespace: Febucci.UI.Core
Assembly: Febucci.TextAnimator.Runtime.dll
Syntax
public abstract class TAnimPlayerBase : MonoBehaviour
Remarks
If you want to use the default TextAnimatorPlayer, see: TextAnimatorPlayer
You can also create custom typewriters by inheriting from this class.
Manual: Writing Custom TextAnimatorPlayers (C#)
Fields
disappearanceOrientation
Declaration
public TAnimPlayerBase.DisappearanceOrientation disappearanceOrientation
Field Value
Type | Description |
---|---|
TAnimPlayerBase.DisappearanceOrientation |
onCharacterVisible
Called once a character has been shown by the typewriter.
It is only invoked when the typewriter is enabled.
Declaration
public CharacterEvent onCharacterVisible
Field Value
Type | Description |
---|---|
Febucci.UI.Core.CharacterEvent |
onTextDisappeared
Callend once the typewriter has completed hiding all the letters.
Declaration
public UnityEvent onTextDisappeared
Field Value
Type | Description |
---|---|
UnityEngine.Events.UnityEvent |
onTextShowed
Called once the text is completely shown.
If the typewriter is enabled, this event is called once it has ended showing all letters.
Declaration
public UnityEvent onTextShowed
Field Value
Type | Description |
---|---|
UnityEngine.Events.UnityEvent |
onTypewriterStart
Called once the typewriter starts showing text.
It is only invoked when the typewriter is enabled.
Declaration
public UnityEvent onTypewriterStart
Field Value
Type | Description |
---|---|
UnityEngine.Events.UnityEvent |
typewriterPlayerSpeed
Typewriter's speed (acts like a multiplier)
You can change this value or invoke SetTypewriterSpeed(Single)
Declaration
protected float typewriterPlayerSpeed
Field Value
Type | Description |
---|---|
Single |
useTypeWriter
true
if the typewriter is enabled
Declaration
public bool useTypeWriter
Field Value
Type | Description |
---|---|
Boolean |
wantsToSkip
true
if the player wants to skip the typewriter.
You can check/modify its value and also call SkipTypewriter() to set it to true
.
Declaration
protected bool wantsToSkip
Field Value
Type | Description |
---|---|
Boolean |
Remarks
P.S. It is reset back to false
every time you show a new text.
Properties
isBaseInsideRoutine
true
if the typewriter is currently showing letters.
Declaration
protected bool isBaseInsideRoutine { get; }
Property Value
Type | Description |
---|---|
Boolean |
isWaitingForPlayerInput
true
if the typewriter is waiting for the player input in the 'waitinput' action tag
Declaration
public bool isWaitingForPlayerInput { get; }
Property Value
Type | Description |
---|---|
Boolean |
textAnimator
The TextAnimator Component linked to this typewriter
Declaration
public TextAnimator textAnimator { get; }
Property Value
Type | Description |
---|---|
TextAnimator |
Methods
DoCustomAction(TypewriterAction)
Override this method in order to implement custom actions in your typewriter.
- Manual: Writing Custom Actions C#
Declaration
protected virtual IEnumerator DoCustomAction(TypewriterAction action)
Parameters
Type | Name | Description |
---|---|---|
TypewriterAction | action |
Returns
Type | Description |
---|---|
IEnumerator |
GetWaitAppearanceTimeOf(Char)
Returns the typewriter's appearance waiting time based on a given character/letter.
Declaration
protected abstract float GetWaitAppearanceTimeOf(char character)
Parameters
Type | Name | Description |
---|---|---|
Char | character |
Returns
Type | Description |
---|---|
Single |
Remarks
You can customize this in your custom typewriter for your game.
Some variables/methods that you could use here:
Examples
Waiting more time if the character is puntuaction.
protected override float WaitTimeOf(char character)
{
if (char.IsPunctuation(character))
return .06f;
return .03f;
}
GetWaitDisappearanceTimeOf(Char)
Returns the typewriter's disappearance waiting time based on a given character/letter.
Declaration
protected virtual float GetWaitDisappearanceTimeOf(char character)
Parameters
Type | Name | Description |
---|---|---|
Char | character |
Returns
Type | Description |
---|---|
Single |
Remarks
You can customize this in your custom typewriter for your game.
OnDisable()
Unity's default MonoBehavior 'OnDisable' callback.
Declaration
protected virtual void OnDisable()
Remarks
P.S. If you're overriding this method, don't forget to invoke the base one.
OnEnable()
Unity's default MonoBehavior 'OnEnable' callback.
Declaration
protected virtual void OnEnable()
Remarks
P.S. If you're overriding this method, don't forget to invoke the base one.
OnTypewriterCharDelay()
Invoked for every frame the typewriter is waiting to show the next letter.
Declaration
protected virtual void OnTypewriterCharDelay()
Remarks
You could use this in order to speed up the waiting time based on the player input.
SetTypewriterSpeed(Single)
Makes the typewriter slower/faster, by setting its internal speed multiplier.
Declaration
public void SetTypewriterSpeed(float value)
Parameters
Type | Name | Description |
---|---|---|
Single | value |
Remarks
The minimum value is 0.001
Examples
If the typewriter has to wait 1
second to show the next letter but you set the typewriter speed to 2
, the typewriter will wait 0.5
seconds.
ShowText(String)
Sets the TextAnimator text. If enabled, it also starts showing letters dynamically.
- Manual: Text Animator Players
Declaration
public void ShowText(string text)
Parameters
Type | Name | Description |
---|---|---|
String | text |
Remarks
If the typewriter is enabled but its start mode (editable in the Inspector) doesn't include Febucci.UI.Core.TAnimPlayerBase.StartTypewriterMode.OnShowText, this method won't start showing letters. You'd have to manually call StartShowingText(Boolean) in order to start the typewriter, or include different "start modes" like Febucci.UI.Core.TAnimPlayerBase.StartTypewriterMode.OnEnable and let the script manage it automatically.
SkipTypewriter()
Declaration
public void SkipTypewriter()
StartDisappearingText()
Starts disappearing the text dynamically
Declaration
public void StartDisappearingText()
StartShowingText(Boolean)
Starts showing letters dynamically
Declaration
public void StartShowingText(bool resetVisibleCharacters = false)
Parameters
Type | Name | Description |
---|---|---|
Boolean | resetVisibleCharacters | if you want the typewriter to resume where it was left. if the typewriter should restart from character 0
|
StopDisappearingText()
Stops the typewriter's from disappearing the text dynamically, leaving the text at its current state
Declaration
public void StopDisappearingText()
StopShowingText()
Stops showing letters dynamically, leaving the text as it is.
Declaration
public void StopShowingText()
WaitInput()
Waits for user input in order to continue showing text. Invoked when there is a waitinput action tag (Manual: Performing Actions while Typing)
Declaration
protected abstract IEnumerator WaitInput()
Returns
Type | Description |
---|---|
IEnumerator |
Remarks
You can customize this based on your project inputs.