AutoType

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
(New page: Author: Daniel == Description == Automaticlly types a string of text typewriter style. == Usage == Place this script onto a GUIText. == Javascript - AutoType.js == var word = "Hello ...)
 
m (Added proper tags for syntax highlighting)
Line 2: Line 2:
  
 
== Description ==
 
== Description ==
Automaticlly types a string of text typewriter style.
+
Automatically types a string of text typewriter style.
  
 
== Usage ==
 
== Usage ==
Line 9: Line 9:
 
== Javascript - AutoType.js ==
 
== Javascript - AutoType.js ==
  
 +
<javascript>var word = "Hello World";
 +
var letterPause = 0.2;
 +
var sound : AudioClip;
  
var word = "Hello World";
+
function Start () {
var letterPause = 0.2;
+
guiText.text = "";
var sound : AudioClip;
+
TypeText ();
+
}
function Start () {
+
 
guiText.text = "";
+
function TypeText () {
TypeText ();
+
for (var i = 0; i < word.Length; i++) {
}
+
guiText.text += word[i];
+
if (sound)
function TypeText () {
+
audio.PlayOneShot (sound);
for (var i = 0; i < word.Length; i++) {
+
yield WaitForSeconds (letterPause);
guiText.text += word[i];
+
}
if (sound)
+
}</javascript>
audio.PlayOneShot (sound);
+
yield WaitForSeconds (letterPause);
+
}
+
}
+

Revision as of 23:32, 2 June 2007

Author: Daniel

Description

Automatically types a string of text typewriter style.

Usage

Place this script onto a GUIText.

Javascript - AutoType.js

<javascript>var word = "Hello World"; var letterPause = 0.2; var sound : AudioClip;

function Start () { guiText.text = ""; TypeText (); }

function TypeText () { for (var i = 0; i < word.Length; i++) { guiText.text += word[i]; if (sound) audio.PlayOneShot (sound); yield WaitForSeconds (letterPause); } }</javascript>

Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox