topical media & game development
lib-unity-book-09-BackButtonGUI-ch-9.js / js
/* Script Provided by Will Goldstone as part of Unity Game Development Essentials book assets */
/* Please Do Not Remove this comment - this script is for reference only */
var beep : AudioClip;
var menuSkin : GUISkin;
var areaWidth : float;
var areaHeight : float;
function OnGUI(){
GUI.skin = menuSkin;
var ScreenX = ((Screen.width / 2) - (areaWidth / 2));
var ScreenY = ((Screen.height / 1.7) - (areaHeight / 2));
GUILayout.BeginArea (Rect (ScreenX,ScreenY, areaWidth, areaHeight));
if(GUILayout.Button ("Back")){
OpenLevel("Menu");
}
GUILayout.EndArea();
}
function OpenLevel(level : String){
audio.PlayOneShot(beep);
yield new WaitForSeconds(0.35);
Application.LoadLevel(level);
}
@script RequireComponent(AudioSource)
(C) Æliens
04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.