// Main Menu Script
Синтаксис:
Используется javascript
var window = 0;
var myFont : Font;
var style : GUIStyle;
var toggle = false; //тумблер
static var soundFloat : float = 1.0;
//
function OnGUI ()
{
AudioListener.volume = soundFloat; //применяем громкость
if (Input.GetKey("f1"))
{
window = 2;
}
GUI.skin.font = myFont;
if (window == 0) // теперь главное меню активировано при window = 0
{
GUI.Box (Rect (Screen.width/2 - 100,Screen.height/2 - 100,200,180), "ГЛАВНОЕ МЕНЮ");
if (GUI.Button (Rect (Screen.width/2 - 90,Screen.height/2 - 80,180,30), "Играть"))
{
Application.LoadLevel ("sceneLevel1");
}
if (GUI.Button (Rect (Screen.width/2 - 90,Screen.height/2 - 40,180,30), "Настройки"))
{
window = 1; // активируем окно "настройки"
}
if (GUI.Button (Rect (Screen.width/2 - 90,Screen.height/2 - 0,180,30), "Помощь"))
{
window = 2; // активируем окно "помощь"
}
if (GUI.Button (Rect (Screen.width/2 - 90,Screen.height/2 + 40,180,30), "Выход"))
{
Application.Quit();
}
}
if (window == 1) // наши настройки
{
GUI.Box (Rect (Screen.width/2 - 100,Screen.height/2 - 100,200,180), "Настройки");
GUI.Label (Rect (Screen.width/2 - 90,Screen.height/2 - 70, 180, 20), "Громкость музыки:");
soundFloat = GUI.HorizontalSlider (Rect (Screen.width/2 - 90,Screen.height/2 - 50, 180, 20), soundFloat, 0.0, 1.0); //ползунок, регулирующий громкость
toggle = GUI.Toggle (Rect (Screen.width/2 - 90,Screen.height/2 - 20, 180, 20), toggle, "На весь экран");
if (toggle == true)
{
Screen.SetResolution(Screen.currentResolution.width, Screen.currentResolution.height, true);
}
else
{
Screen.SetResolution(800, 600, false);
}
if (GUI.Button (Rect (Screen.width/2 - 90,Screen.height/2 + 40,180,30), "Назад") || Input.GetKey ("escape"))
{
window = 0;
}
}
if (window == 2) // наша помощь
{
GUI.Box (Rect (Screen.width/2 - 100,Screen.height/2 - 100,200,180), "Помощь");
GUI.Label (Rect (Screen.width/2 - 100,Screen.height/2 - 80,200,140), "Здесь должна быть помощь ", style); // текст
if (GUI.Button (Rect (Screen.width/2 - 90,Screen.height/2 + 40,180,30), "Назад") || Input.GetKey ("escape"))
{
window = 0;
}
}
}
var myFont : Font;
var style : GUIStyle;
var toggle = false; //тумблер
static var soundFloat : float = 1.0;
//
function OnGUI ()
{
AudioListener.volume = soundFloat; //применяем громкость
if (Input.GetKey("f1"))
{
window = 2;
}
GUI.skin.font = myFont;
if (window == 0) // теперь главное меню активировано при window = 0
{
GUI.Box (Rect (Screen.width/2 - 100,Screen.height/2 - 100,200,180), "ГЛАВНОЕ МЕНЮ");
if (GUI.Button (Rect (Screen.width/2 - 90,Screen.height/2 - 80,180,30), "Играть"))
{
Application.LoadLevel ("sceneLevel1");
}
if (GUI.Button (Rect (Screen.width/2 - 90,Screen.height/2 - 40,180,30), "Настройки"))
{
window = 1; // активируем окно "настройки"
}
if (GUI.Button (Rect (Screen.width/2 - 90,Screen.height/2 - 0,180,30), "Помощь"))
{
window = 2; // активируем окно "помощь"
}
if (GUI.Button (Rect (Screen.width/2 - 90,Screen.height/2 + 40,180,30), "Выход"))
{
Application.Quit();
}
}
if (window == 1) // наши настройки
{
GUI.Box (Rect (Screen.width/2 - 100,Screen.height/2 - 100,200,180), "Настройки");
GUI.Label (Rect (Screen.width/2 - 90,Screen.height/2 - 70, 180, 20), "Громкость музыки:");
soundFloat = GUI.HorizontalSlider (Rect (Screen.width/2 - 90,Screen.height/2 - 50, 180, 20), soundFloat, 0.0, 1.0); //ползунок, регулирующий громкость
toggle = GUI.Toggle (Rect (Screen.width/2 - 90,Screen.height/2 - 20, 180, 20), toggle, "На весь экран");
if (toggle == true)
{
Screen.SetResolution(Screen.currentResolution.width, Screen.currentResolution.height, true);
}
else
{
Screen.SetResolution(800, 600, false);
}
if (GUI.Button (Rect (Screen.width/2 - 90,Screen.height/2 + 40,180,30), "Назад") || Input.GetKey ("escape"))
{
window = 0;
}
}
if (window == 2) // наша помощь
{
GUI.Box (Rect (Screen.width/2 - 100,Screen.height/2 - 100,200,180), "Помощь");
GUI.Label (Rect (Screen.width/2 - 100,Screen.height/2 - 80,200,140), "Здесь должна быть помощь ", style); // текст
if (GUI.Button (Rect (Screen.width/2 - 90,Screen.height/2 + 40,180,30), "Назад") || Input.GetKey ("escape"))
{
window = 0;
}
}
}