Created
September 9, 2019 13:08
-
-
Save edwardrowe/aa5fa3150d5d8c060eabf19f276746eb to your computer and use it in GitHub Desktop.
Code used in reference to a comment on TextTyper blog. https://medium.com/@111896christopher/hey-edward-rowe-d7c78d08a124
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEngine.UI; | |
using RedBlueGames.Tools.TextTyper; | |
public class CVExample : MonoBehaviour | |
{ | |
[SerializeField] | |
private InputField textInputField; | |
[SerializeField] | |
private Button submitInput; | |
[SerializeField] | |
private TextTyper typer; | |
private Dictionary<string, string> responses; | |
private void Awake() | |
{ | |
this.typer.PrintCompleted.AddListener(this.HandlePrintCompleted); | |
this.submitInput.onClick.AddListener(this.HandleSubmit); | |
} | |
private void HandleSubmit() | |
{ | |
var input = this.textInputField.text; | |
if (this.responses.ContainsKey(input)) | |
{ | |
var response = this.responses[input]; | |
this.BeginPrintingText(response); | |
} | |
} | |
private void BeginPrintingText(string text) | |
{ | |
this.typer.TypeText(text); | |
// Deactivate the buttons | |
} | |
private void HandlePrintCompleted() | |
{ | |
// Activate the buttons here | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment