Coder Social home page Coder Social logo

rpg-text-system's Introduction

RPG-Text-System

A system for displaying text in Unity like in old RPG games.

Usage

  1. Add TextHandler prefab to your scene. Screenshot 1
  2. Or, create a new object and attach the TextHandler script, and a AudioSource in the inspector Screenshot 2
  3. Link the "Text Box" field in the TextHandler script to a textbox in the scene
    Screenshot 3
  4. In another script/object, or internally within TextHandler, create a new Voice(). Voice() takes 4 parameters for its constructor: 1. float rate: How time, in seconds, between each character reveal 2. float low: The pitch of the lowest possible note (Expressed as a pitch coefficient) 3. float high: The pitch of the highest possible note 4. AudioClip sound: A reference to a AudioClip to be played when revealing notes. (See Unity documentation)
  5. Link the Voice to TextHandler using TextHandler.SetVoice(Voice v) For example: GetComponent().SetVoice(new Voice(0.1f, 1, 5, sound));
  6. Give TextHandler an array of strings to display using TextHandler.SetText(string[] newText)
  7. Now, call TextHandler.AdvanceLine() to start advancing lines. (By default, this is set to OnMouseUp)

Example Scene

Included is a Example.unity scene is included to show how to properly load TextHandler and use it. Within TextHandler.cs, Void Start(), uncomment these lines to try it out:

AudioClip sound = Resources.Load("bleep") as AudioClip;
Voice v = new Voice(0.1f, 1, 3, sound);

string [] examples = {"Hello world!", "Test text!"};

SetVoice(v);
SetText(examples);

License

CC0

rpg-text-system's People

Contributors

centribo avatar

Watchers

 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.