Saturday 17 January 2015

Contoh Script button show pada UNity3D

Buttonshow.cs
using UnityEngine;
using System.Collections;

public class buttonshow : MonoBehaviour {

public Texture2D background;
private string clicked = "";
private void OnGUI()
{
if (background != null)
GUI.DrawTexture(new Rect(0,0,Screen.width , Screen.height), background);
if (clicked == "" || clicked == "Show" )
{
if( GUI.Button( new Rect(20, 30, 100, 50 ),"<size=16>Show</size>"))
{
clicked = "Show";
}
else if (clicked == "Show")
{

GUI. Window(0,new Rect(Screen.width/4 - 80,Screen.height/4 - 80,500,350) , optionsFunc , "<size=14>Keterangan</size>");
}
}
}
private void optionsFunc(int id)
{
GUI.Box(new Rect(0, 20,500, 500),
"\n"+      
"\n"+
"<size=16>Merek Baju :</size>\n"+
"<size=16>Marker 1 BTS,Marker 2 EXO,Marker 3 Infinite,Marker 4 BAP\n\n</size>" +

"<size=16>Bahan :\n</size>"+
"<size=16>Menggunakan bahan catoon\n\n</size>" +
                                               
"<size=16>Warna :\n</size>"+
"<size=16>Hitam,Putih,Merah,Biru,Abu-abu\n\n</size>" +
                                               
"<size=16>Size : \n</size>" +
"<size=16>S, M, L, XL, XXL, XXXL\n</size>" +
"<size=16>(kisaran harga 80.000-250.000)</size>");


if( GUI.Button( new Rect(420, 295, 50, 25 ),"<size=14>Oke</size>"))
{
clicked = "";
}
}
}


Download script Link1 / Link2




No comments:

Post a Comment