Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class SuperTextFromACSpeech : MonoBehaviour {
- /*
- This script is to make Super Text Mesh work with Adventure Creator.
- Essentially, it lets AC handle all non-text elements (sound effects, user input),
- while letting STM handle all text-related issues (scrolling speed, animations, colors, etc.)
- Simply put this script on a Super Text ui item in your subtitlesUI adventure creator menu,
- then hide the text item that AC thinks it's referencing (put it offscreen, make it invisible, whatever!).
- AC will play dialogue sounds and handle input as normal,
- but the player will only see the Super Text.
- Script by @johndaguerra. No credit needed, but I'm cool and it'd make me happy if you followed me on twitter!
- */
- SuperTextMesh supertext;
- AC.Speech speech;
- AC.Dialog dialog;
- void Start () {
- supertext = GetComponent<SuperTextMesh>();
- dialog = FindObjectOfType<AC.Dialog>();
- }
- void Update () {
- //If there is dialogue currently being spoken...
- if (dialog.GetLatestSpeech() != null)
- {
- //And you haven't already sampled it...
- if (speech != dialog.GetLatestSpeech())
- {
- //Then set the supertext text to print the dialogue
- speech = dialog.GetLatestSpeech();
- supertext.color = speech.GetColour ();
- supertext.Text = speech.log.fullText;
- //This tells the text to read at regular speeds, in case it was told to speed read
- supertext.RegularRead();
- }
- }
- if (supertext.reading == true)
- {
- if (Input.GetMouseButtonDown(0) || Input.GetKeyDown("space"))
- {
- //If the player clicks or presses space while reading, then speed read
- supertext.SpeedRead();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement