SHARE
TWEET

SuperTextFromACSpeech

MisterSugarcube Sep 21st, 2016 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class SuperTextFromACSpeech : MonoBehaviour {
  5.     /*
  6.     This script is to make Super Text Mesh work with Adventure Creator.
  7.     Essentially, it lets AC handle all non-text elements (sound effects, user input),
  8.     while letting STM handle all text-related issues (scrolling speed, animations, colors, etc.)
  9.  
  10.     Simply put this script on a Super Text ui item in your subtitlesUI adventure creator menu,
  11.     then hide the text item that AC thinks it's referencing (put it offscreen, make it invisible, whatever!).
  12.  
  13.     AC will play dialogue sounds and handle input as normal,
  14.     but the player will only see the Super Text.
  15.  
  16.     Script by @johndaguerra.  No credit needed, but I'm cool and it'd make me happy if you followed me on twitter!
  17.     */
  18.     SuperTextMesh supertext;
  19.     AC.Speech speech;
  20.     AC.Dialog dialog;
  21.  
  22.     void Start () {
  23.         supertext = GetComponent<SuperTextMesh>();
  24.         dialog = FindObjectOfType<AC.Dialog>();
  25.     }
  26.    
  27.     void Update () {
  28.         //If there is dialogue currently being spoken...
  29.         if (dialog.GetLatestSpeech() != null)
  30.         {
  31.             //And you haven't already sampled it...
  32.             if (speech != dialog.GetLatestSpeech())
  33.             {
  34.                 //Then set the supertext text to print the dialogue
  35.                 speech = dialog.GetLatestSpeech();
  36.                 supertext.Text = speech.log.fullText;
  37.                 //This tells the text to read at regular speeds, in case it was told to speed read
  38.                 supertext.RegularRead();
  39.             }
  40.         }
  41.  
  42.         if (supertext.reading == true)
  43.         {
  44.             if (Input.GetMouseButtonDown(0) || Input.GetKeyDown("space"))
  45.             {
  46.                 //If the player clicks or presses space while reading, then speed read
  47.                 supertext.SpeedRead();
  48.             }
  49.         }
  50.  
  51.     }
  52. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top