Saturday 17 January 2015

Contoh Script java exit pada UNity3D

button exit.js
#pragma strict
var exitNormal : Texture2D;
var exitHover : Texture2D;
var beep : AudioClip;
var GuiOn = false;

function Start () {

}

function OnMouseEnter () {

guiTexture.texture = exitHover;
renderer.material.color = Color.green;
}

function OnMouseExit() {

guiTexture.texture = exitNormal;
renderer.material.color = Color.white;
}
function OnGUI () {
    if(GuiOn){//check if gui should be on. If false, the gui is off, if true,the gui is on
    // Make a background box
    GUI.Box (Rect (260,250,510,110),"<color=lightblue><size=20>Are you sure you want to exit Katalog Baju Distro ?</size></color>");
    // Make the first button. If pressed, quit game
    if (GUI.Button (Rect (315,295,100,40), "<color=lightblue><size=20>Yes</size></color>")) {
    Application.Quit();
    }
    // Make the second button.If pressed, sets the var to false sothat gui disappear
    if (GUI.Button (Rect (600,295,100,40), "<color=lightblue><size=20>No</size></color>")) {
    GuiOn=false;
    }
    }
    }
function OnMouseDown () {
audio.PlayOneShot(beep);
yield new WaitForSeconds(0.3);
GuiOn = true;
}



Download script Link1 / Link2








No comments:

Post a Comment