Giter VIP home page Giter VIP logo

unity-text-typer's Introduction

Unity-TextTyper

TextTyper is a text typing effect component for Unity. TextTyper prints out characters one by one to a uGUI Text component. Adapted by RedBlueGames from synchrok's GitHub project (https://github.com/synchrok/TypeText).

It's easy to find other examples of Text printing components, but TextTyper provides two major differences:

  • Correct wrapping as characters are printed
  • Support for Rich Text Tags

How To Use

To start TextTyping all you need to do is add the TextTyper component to a unity Text widget:

  1. Create a GameObject with a Unity UI Text Widget, as normal.
  2. Add a TextTyper component to the GameObject.
  3. Call the TextTyper component's public functions TypeText and Skip to print the desired text with the specified delay. We call these from a 3rd component we call Talker.

You can optionally subscribe to the PrintCompleted and CharacterPrinted UnityEvents to add additional feedback like sounds and paging widgets.

Features

  • Define Text Speed Per Character: Mayday! <delay=0.05>S.O.S.</delay>
  • Support for uGUI Rich Text Tags: <b>,<i>,<size>,<color>,...
  • Additional delay for punctuation
  • Skip to end
  • OnComplete Callback
  • OnCharacterPrinted Callback (for audio)

Screenshots

TypeText Screenshot GIF Image of TextTyper in Sparklite (© RedBlueGames 2016)

The Code

The core of our text typer is a coroutine that’s triggered via the TypeText method. The coroutine has the following steps: Check next character to see if it’s the start of a Rich Text tag

  • If It’s a tag, parse it and apply it. Right now “applying” a tag just means modifying the print delay, but other tags could be added. Add it to a list of tags that need to be closed (because we have not yet reached the corresponding closing tag in our string). Move to next character and repeat
  • If it’s not a tag, print it
  • Wait for the print delay
  • Check if we are complete

The tool also uses RichTextTag.cs, a class that’s used to help with parsing. There are a few details I left out, but this should give you enough to start reading through the code if you want to know more.

How to Help

The easiest way to help with the project is to just to use it! As you use it, you can submit bugs and feature requests through GitHub issues.

Contributors

Issue Resporters

  • JonathanGorr

License and Credits

  • TypeText is under MIT license. See the LICENSE file for more info.
  • Typing sound effect (UITextDisplay.wav) provided by @kevinrmabie. Free for others to use, no attribution necessary.

unity-text-typer's People

Contributors

edwardrowe avatar synchrok avatar devxoul avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.