PixelCrushers.DialogueSystem.UnityUITypewriterEffect Class Reference

This is a typewriter effect for Unity UI. More...

Inheritance diagram for PixelCrushers.DialogueSystem.UnityUITypewriterEffect:
Collaboration diagram for PixelCrushers.DialogueSystem.UnityUITypewriterEffect:

Classes

class  AutoScrollSettings
 
class  Token
 

Public Member Functions

override void Awake ()
 
override void Start ()
 
override void OnEnable ()
 
override void OnDisable ()
 
virtual void Pause ()
 Pauses the effect.
 
virtual void Unpause ()
 Unpauses the effect.
 
override void StartTyping (string text, int fromIndex=0)
 
override void StopTyping ()
 
virtual void PlayText (string text, int fromIndex=0)
 Play typewriter on text immediately.
 
virtual IEnumerator Play (int fromIndex=0)
 Plays the typewriter effect.
 
override void Stop ()
 Stops the effect.
 
- Public Member Functions inherited from PixelCrushers.DialogueSystem.AbstractTypewriterEffect
virtual float GetSpeed ()
 Returns the typewriter's charactersPerSecond.
 
virtual void SetSpeed (float charactersPerSecond)
 Sets the typewriter's charactersPerSecond.
 
void Start ()
 
virtual void StopOnConversationEnd (Transform actor)
 
void Stop ()
 
void StartTyping (string text, int fromIndex=0)
 
void StopTyping ()
 
virtual void StopCharacterAudio ()
 

Public Attributes

AutoScrollSettings autoScrollSettings = new AutoScrollSettings()
 Optional auto-scroll settings.
 
UnityEvent onBegin = new UnityEvent()
 
UnityEvent onCharacter = new UnityEvent()
 
UnityEvent onEnd = new UnityEvent()
 
- Public Attributes inherited from PixelCrushers.DialogueSystem.AbstractTypewriterEffect
bool rightToLeft = false
 Set true to type right to left.
 
float charactersPerSecond = 50
 How fast to "type.".
 
AudioClip audioClip = null
 The audio clip to play with each character.
 
AudioClip[] alternateAudioClips = new AudioClip[0]
 If specified, randomly use these clips or the main Audio Clip.
 
AudioSource audioSource = null
 The audio source through which to play the clip.
 
bool usePlayOneShot = false
 
bool interruptAudioClip = false
 If audio clip is still playing from previous character, stop and restart it when typing next character.
 
bool stopAudioOnSilentCharacters = false
 
bool stopAudioOnPauseCodes = false
 
string silentCharacters = string.Empty
 Don't play audio on these characters.
 
string fullPauseCharacters = string.Empty
 Play a full pause on these characters.
 
string quarterPauseCharacters = string.Empty
 Play a quarter pause on these characters.
 
float fullPauseDuration = 1f
 Duration to pause on when text contains '\.
 
float quarterPauseDuration = 0.25f
 Duration to pause when text contains '\,'.
 
bool removeDuplicateTypewriterEffects = true
 Ensures this GameObject has only one typewriter effect.
 
bool playOnEnable = true
 Play using the current text content whenever component is enabled.
 
bool waitOneFrameBeforeStarting = false
 Wait one frame to allow layout elements to setup first.
 
bool stopOnConversationEnd = false
 Stop typing when the conversation ends.
 

Protected Types

enum  TokenType {
  Character , BoldOpen , BoldClose , ItalicOpen ,
  ItalicClose , ColorOpen , ColorClose , SizeOpen ,
  SizeClose , Quad , Pause , InstantOpen ,
  InstantClose
}
 

Protected Member Functions

void RemoveIfDuplicate ()
 
virtual void StartTypewriterCoroutine (int fromIndex)
 
Token GetNextToken (List< Token > tokens)
 
void OpenRichText (StringBuilder current, Token token, List< TokenType > openTokens)
 
void CloseRichText (StringBuilder current, Token token, List< TokenType > openTokens)
 
void AddInstantText (StringBuilder current, List< TokenType > openTokenTypes, List< Token > tokens)
 
string GetCurrentText (StringBuilder current, List< TokenType > openTokenTypes, List< Token > tokens, bool withoutTransparentText=false)
 
List< TokenTokenize (string text)
 
Token TryTokenize (string code, TokenType tokenType, float duration, ref string remainder)
 
Token TryTokenizeColorOpen (ref string remainder)
 
Token TryTokenizeSizeOpen (ref string remainder)
 
Token TryTokenizeQuad (ref string remainder)
 
virtual void StopTypewriterCoroutine ()
 
void InitAutoScroll ()
 
void HandleAutoScroll (bool jumpToEnd)
 
IEnumerator HandleAutoScrollAfterOneFrame (bool jumpToEnd)
 
- Protected Member Functions inherited from PixelCrushers.DialogueSystem.AbstractTypewriterEffect
virtual void PreprocessPauseCharacters ()
 Process anything special in full/quarterPauseCharacters, such as
to newlines.
 
virtual bool IsFullPauseCharacter (char c)
 
virtual bool IsQuarterPauseCharacter (char c)
 
virtual bool IsSilentCharacter (char c)
 
bool IsCharacterInString (char c, string s)
 
virtual void PlayCharacterAudio (char c)
 
virtual void PlayCharacterAudio ()
 
virtual IEnumerator PauseForDuration (float duration)
 

Protected Attributes

UnityEngine.UI.Text control
 
bool started = false
 
string original = null
 
string frontSkippedText = string.Empty
 
Coroutine typewriterCoroutine = null
 
MonoBehaviour coroutineController = null
 
StringBuilder current
 
List< TokenTypeopenTokenTypes
 
List< Tokentokens
 
int MaxSafeguard = 16384
 
- Protected Attributes inherited from PixelCrushers.DialogueSystem.AbstractTypewriterEffect
bool paused = false
 

Static Protected Attributes

const string RichTextBoldOpen = "<b>"
 
const string RichTextBoldClose = "</b>"
 
const string RichTextItalicOpen = "<i>"
 
const string RichTextItalicClose = "</i>"
 
const string RichTextColorOpenPrefix = "<color="
 
const string RichTextColorClose = "</color>"
 
const string RichTextSizeOpenPrefix = "<size="
 
const string RichTextSizeClose = "</size>"
 
const string QuadPrefix = "<quad "
 

Properties

override bool isPlaying [get]
 Indicates whether the effect is playing.
 
- Properties inherited from PixelCrushers.DialogueSystem.AbstractTypewriterEffect
bool isPlaying [get]
 

Additional Inherited Members

- Static Public Member Functions inherited from PixelCrushers.DialogueSystem.AbstractTypewriterEffect
static string StripRPGMakerCodes (string s)
 

Detailed Description

This is a typewriter effect for Unity UI.

It handles bold, italic, quad, and color rich text tags and certain RPGMaker-style tags. It also works with any text alignment.

Member Enumeration Documentation

◆ TokenType

Enumerator
Character 
BoldOpen 
BoldClose 
ItalicOpen 
ItalicClose 
ColorOpen 
ColorClose 
SizeOpen 
SizeClose 
Quad 
Pause 
InstantOpen 
InstantClose 

Member Function Documentation

◆ AddInstantText()

void PixelCrushers.DialogueSystem.UnityUITypewriterEffect.AddInstantText ( StringBuilder  current,
List< TokenType openTokenTypes,
List< Token tokens 
)
inlineprotected

◆ Awake()

override void PixelCrushers.DialogueSystem.UnityUITypewriterEffect.Awake ( )
inlinevirtual

◆ CloseRichText()

void PixelCrushers.DialogueSystem.UnityUITypewriterEffect.CloseRichText ( StringBuilder  current,
Token  token,
List< TokenType openTokens 
)
inlineprotected

◆ GetCurrentText()

string PixelCrushers.DialogueSystem.UnityUITypewriterEffect.GetCurrentText ( StringBuilder  current,
List< TokenType openTokenTypes,
List< Token tokens,
bool  withoutTransparentText = false 
)
inlineprotected

◆ GetNextToken()

Token PixelCrushers.DialogueSystem.UnityUITypewriterEffect.GetNextToken ( List< Token tokens)
inlineprotected

◆ HandleAutoScroll()

void PixelCrushers.DialogueSystem.UnityUITypewriterEffect.HandleAutoScroll ( bool  jumpToEnd)
inlineprotected

◆ HandleAutoScrollAfterOneFrame()

IEnumerator PixelCrushers.DialogueSystem.UnityUITypewriterEffect.HandleAutoScrollAfterOneFrame ( bool  jumpToEnd)
inlineprotected

◆ InitAutoScroll()

void PixelCrushers.DialogueSystem.UnityUITypewriterEffect.InitAutoScroll ( )
inlineprotected

◆ OnDisable()

override void PixelCrushers.DialogueSystem.UnityUITypewriterEffect.OnDisable ( )
inlinevirtual

◆ OnEnable()

override void PixelCrushers.DialogueSystem.UnityUITypewriterEffect.OnEnable ( )
inlinevirtual

◆ OpenRichText()

void PixelCrushers.DialogueSystem.UnityUITypewriterEffect.OpenRichText ( StringBuilder  current,
Token  token,
List< TokenType openTokens 
)
inlineprotected

◆ Pause()

virtual void PixelCrushers.DialogueSystem.UnityUITypewriterEffect.Pause ( )
inlinevirtual

Pauses the effect.

◆ Play()

virtual IEnumerator PixelCrushers.DialogueSystem.UnityUITypewriterEffect.Play ( int  fromIndex = 0)
inlinevirtual

Plays the typewriter effect.

◆ PlayText()

virtual void PixelCrushers.DialogueSystem.UnityUITypewriterEffect.PlayText ( string  text,
int  fromIndex = 0 
)
inlinevirtual

Play typewriter on text immediately.

Parameters
text

◆ RemoveIfDuplicate()

void PixelCrushers.DialogueSystem.UnityUITypewriterEffect.RemoveIfDuplicate ( )
inlineprotected

◆ Start()

override void PixelCrushers.DialogueSystem.UnityUITypewriterEffect.Start ( )
inline

◆ StartTypewriterCoroutine()

virtual void PixelCrushers.DialogueSystem.UnityUITypewriterEffect.StartTypewriterCoroutine ( int  fromIndex)
inlineprotectedvirtual

◆ StartTyping()

override void PixelCrushers.DialogueSystem.UnityUITypewriterEffect.StartTyping ( string  text,
int  fromIndex = 0 
)
inline

◆ Stop()

override void PixelCrushers.DialogueSystem.UnityUITypewriterEffect.Stop ( )
inline

Stops the effect.

◆ StopTypewriterCoroutine()

virtual void PixelCrushers.DialogueSystem.UnityUITypewriterEffect.StopTypewriterCoroutine ( )
inlineprotectedvirtual

◆ StopTyping()

override void PixelCrushers.DialogueSystem.UnityUITypewriterEffect.StopTyping ( )
inline

◆ Tokenize()

List< Token > PixelCrushers.DialogueSystem.UnityUITypewriterEffect.Tokenize ( string  text)
inlineprotected

◆ TryTokenize()

Token PixelCrushers.DialogueSystem.UnityUITypewriterEffect.TryTokenize ( string  code,
TokenType  tokenType,
float  duration,
ref string  remainder 
)
inlineprotected

◆ TryTokenizeColorOpen()

Token PixelCrushers.DialogueSystem.UnityUITypewriterEffect.TryTokenizeColorOpen ( ref string  remainder)
inlineprotected

◆ TryTokenizeQuad()

Token PixelCrushers.DialogueSystem.UnityUITypewriterEffect.TryTokenizeQuad ( ref string  remainder)
inlineprotected

◆ TryTokenizeSizeOpen()

Token PixelCrushers.DialogueSystem.UnityUITypewriterEffect.TryTokenizeSizeOpen ( ref string  remainder)
inlineprotected

◆ Unpause()

virtual void PixelCrushers.DialogueSystem.UnityUITypewriterEffect.Unpause ( )
inlinevirtual

Unpauses the effect.

The text will resume at the point where it was paused; it won't try to catch up to make up for the pause.

Member Data Documentation

◆ autoScrollSettings

AutoScrollSettings PixelCrushers.DialogueSystem.UnityUITypewriterEffect.autoScrollSettings = new AutoScrollSettings()

Optional auto-scroll settings.

◆ control

UnityEngine.UI.Text PixelCrushers.DialogueSystem.UnityUITypewriterEffect.control
protected

◆ coroutineController

MonoBehaviour PixelCrushers.DialogueSystem.UnityUITypewriterEffect.coroutineController = null
protected

◆ current

StringBuilder PixelCrushers.DialogueSystem.UnityUITypewriterEffect.current
protected

◆ frontSkippedText

string PixelCrushers.DialogueSystem.UnityUITypewriterEffect.frontSkippedText = string.Empty
protected

◆ MaxSafeguard

int PixelCrushers.DialogueSystem.UnityUITypewriterEffect.MaxSafeguard = 16384
protected

◆ onBegin

UnityEvent PixelCrushers.DialogueSystem.UnityUITypewriterEffect.onBegin = new UnityEvent()

◆ onCharacter

UnityEvent PixelCrushers.DialogueSystem.UnityUITypewriterEffect.onCharacter = new UnityEvent()

◆ onEnd

UnityEvent PixelCrushers.DialogueSystem.UnityUITypewriterEffect.onEnd = new UnityEvent()

◆ openTokenTypes

List<TokenType> PixelCrushers.DialogueSystem.UnityUITypewriterEffect.openTokenTypes
protected

◆ original

string PixelCrushers.DialogueSystem.UnityUITypewriterEffect.original = null
protected

◆ QuadPrefix

const string PixelCrushers.DialogueSystem.UnityUITypewriterEffect.QuadPrefix = "<quad "
staticprotected

◆ RichTextBoldClose

const string PixelCrushers.DialogueSystem.UnityUITypewriterEffect.RichTextBoldClose = "</b>"
staticprotected

◆ RichTextBoldOpen

const string PixelCrushers.DialogueSystem.UnityUITypewriterEffect.RichTextBoldOpen = "<b>"
staticprotected

◆ RichTextColorClose

const string PixelCrushers.DialogueSystem.UnityUITypewriterEffect.RichTextColorClose = "</color>"
staticprotected

◆ RichTextColorOpenPrefix

const string PixelCrushers.DialogueSystem.UnityUITypewriterEffect.RichTextColorOpenPrefix = "<color="
staticprotected

◆ RichTextItalicClose

const string PixelCrushers.DialogueSystem.UnityUITypewriterEffect.RichTextItalicClose = "</i>"
staticprotected

◆ RichTextItalicOpen

const string PixelCrushers.DialogueSystem.UnityUITypewriterEffect.RichTextItalicOpen = "<i>"
staticprotected

◆ RichTextSizeClose

const string PixelCrushers.DialogueSystem.UnityUITypewriterEffect.RichTextSizeClose = "</size>"
staticprotected

◆ RichTextSizeOpenPrefix

const string PixelCrushers.DialogueSystem.UnityUITypewriterEffect.RichTextSizeOpenPrefix = "<size="
staticprotected

◆ started

bool PixelCrushers.DialogueSystem.UnityUITypewriterEffect.started = false
protected

◆ tokens

List<Token> PixelCrushers.DialogueSystem.UnityUITypewriterEffect.tokens
protected

◆ typewriterCoroutine

Coroutine PixelCrushers.DialogueSystem.UnityUITypewriterEffect.typewriterCoroutine = null
protected

Property Documentation

◆ isPlaying

override bool PixelCrushers.DialogueSystem.UnityUITypewriterEffect.isPlaying
get

Indicates whether the effect is playing.

true if this instance is playing; otherwise, false.


The documentation for this class was generated from the following file: