Синтаксис:
Используется csharp
using UnityEngine;
using System.Collections;
public class Menu : MonoBehaviour {
/******************* GLOBAL PARAMETERS ***********************/
public GUISkin YourGuiSkin;
public bool PlayerMenu_yes_no = false;
/*****************Button Names******************/
public string PlayButton = "Play";
public string AboutButton = "About";
public string OptionsButton = "Options";
public string VideoSetButton = "Video";
public string ExitButton = "Exit";
/******************Info (about) **********/
public string InfoText = "Horror Enige";
/************* VIDEO SETINGS ************/
public string VideoSet = "Video";
public string QuatlyText = "Change Quatly";
public string LowGarfiksQuatlyLVLName = "Low";
public int LowGarfiksQuatlyLVLumber = 0;
public string MediumGarfiksQuatlyLVLName = "medium";
public int MediumGarfiksQuatlyLVLumber = 2;
public string HightGarfiksQuatlyLVLName = "Hight";
public int HightGarfiksQuatlyLVLumber = 3;
public string UltraGarfiksQuatlyLVLName = "Ultra";
public int UltraGarfiksQuatlyLVLumber = 4;
/************ AUDIO SETINGS ************/
public string AudioSet = "Audio";
private float VolumeN;
/**********GAMEPLAY SETINGS*********/
public bool GamePlaySettings = true;
public string GamePlaySet = "GamePlay";
public bool Modes = true;
public int Mode = 2;
public string LowModeT = "LowMode";
public string MediumModeT = "MediumMode";
public string HardModeT = "HardMode";
public string ChangeLevelText = "ChangeLevel";
public string Level1 = "SlenderDemo";
public string Level2 = "DefaultDemo";
public string Level3 = "MainDemo";
public string Level1Name = "SlenderDemo";
public string Level2Name = "DefaultDemo";
public string Level3Name = "MainDemo";
public bool GUIScrimmer = true;
/***************** Exit Options ******************/
public string SureExit = "Are you sure?";
public string Yes = "Yes";
public string NO = "No";
/*OTHER*/
private int window;
public string OptionsName = "GameOptions";
public string BackText = "Back";
void Start () {
window = 1;
}
void OnGUI () {
GUI.skin = YourGuiSkin;
GUI.BeginGroup (new Rect (Screen.width / 2 - 100, Screen.height / 2 - 100, 300, 400));
if(window == 1)
{
if(GUI.Button (new Rect (10,30,180,30), PlayButton))
{
window = 2;
}
if(GUI.Button (new Rect (10,70,180,30), OptionsButton))
{
window = 3;
}
if(GUI.Button (new Rect (10,110,180,30), AboutButton))
{
window = 4;
}
if(GUI.Button (new Rect (10,150,180,30), ExitButton))
{
window = 5;
}
}
if(window == 2)
{
GUI.Label(new Rect(50, 10, 180, 30), ChangeLevelText);
if(GUI.Button (new Rect (10,40,180,30), Level1))
{
Application.LoadLevel(Level1Name);
}
if(GUI.Button (new Rect (10,80,180,30), Level2))
{
Application.LoadLevel(Level2Name);
}
if(GUI.Button (new Rect (10,120,180,30), Level3))
{
Application.LoadLevel(Level3Name);
}
if(GUI.Button (new Rect (10,160,180,30), BackText))
{
window = 1;
}
}
if(window == 3)
{
GUI.Label(new Rect(50, 10, 180, 30), OptionsName);
if(GamePlaySettings == true){
if(GUI.Button (new Rect (10,40,180,30), GamePlaySet))
{
window = 6;
}
}
if(GUI.Button (new Rect (10,80,180,30), AudioSet))
{
window = 7;
}
if(GUI.Button (new Rect (10,120,180,30), VideoSet))
{
window = 8;
}
if(GUI.Button (new Rect (10,160,180,30), BackText))
{
window = 1;
}
}
if(window == 4)
{
GUI.Label(new Rect(50, 10, 180, 30), AboutButton);
GUI.Label(new Rect( 10, 40, 180, 40), InfoText);
if(GUI.Button (new Rect (10,170,180,30), BackText))
{
window = 1;
}
}
if(window == 5)
{
GUI.Label(new Rect(50, 10, 180, 30), SureExit);
if(GUI.Button (new Rect (10,40,180,30), Yes))
{
Application.Quit();
}
if(GUI.Button (new Rect (10,80,180,30), NO))
{
window = 1;
}
}
if(window == 8)
{
if(GUI.Button(new Rect (10,80,180,30), LowGarfiksQuatlyLVLName))
{
QualitySettings.SetQualityLevel (LowGarfiksQuatlyLVLumber);
}
if(GUI.Button(new Rect (10,110,180,30), MediumGarfiksQuatlyLVLName))
{
QualitySettings.SetQualityLevel (MediumGarfiksQuatlyLVLumber);
}
if(GUI.Button(new Rect (10,140,180,30), HightGarfiksQuatlyLVLName))
{
QualitySettings.SetQualityLevel (HightGarfiksQuatlyLVLumber);
}
if(GUI.Button(new Rect (10,170,180,30), UltraGarfiksQuatlyLVLName))
{
QualitySettings.SetQualityLevel (UltraGarfiksQuatlyLVLumber);
}
GUI.Label (new Rect (10,50,180,30), QuatlyText);
if(GUI.Button(new Rect (10,210,180,30), BackText))
{
window = 1;
}
}
if(window == 6){
if(PlayerMenu_yes_no == false){
GUIScrimmer = GUI.Toggle (new Rect (10,80,180,30), GUIScrimmer, "GUIScrimmer");
}
if(GUI.Button(new Rect (10,230,180,30), BackText))
{
window = 1;
}
if(Modes == true){
if(GUI.Button(new Rect (10,140,180,30), LowModeT))
{
Mode = 1;
}
if(GUI.Button(new Rect (10,170,180,30), MediumModeT))
{
Mode = 2;
}
if(GUI.Button(new Rect (10,200,180,30), HardModeT))
{
Mode = 3;
}
}
}
if(window == 7){
VolumeN = GUI.HorizontalSlider(new Rect (10,80,180,30), VolumeN, 5, 10);
if(GUI.Button(new Rect (10,210,180,30), BackText))
{
window = 1;
}
}
GUI.EndGroup ();
}
}
using System.Collections;
public class Menu : MonoBehaviour {
/******************* GLOBAL PARAMETERS ***********************/
public GUISkin YourGuiSkin;
public bool PlayerMenu_yes_no = false;
/*****************Button Names******************/
public string PlayButton = "Play";
public string AboutButton = "About";
public string OptionsButton = "Options";
public string VideoSetButton = "Video";
public string ExitButton = "Exit";
/******************Info (about) **********/
public string InfoText = "Horror Enige";
/************* VIDEO SETINGS ************/
public string VideoSet = "Video";
public string QuatlyText = "Change Quatly";
public string LowGarfiksQuatlyLVLName = "Low";
public int LowGarfiksQuatlyLVLumber = 0;
public string MediumGarfiksQuatlyLVLName = "medium";
public int MediumGarfiksQuatlyLVLumber = 2;
public string HightGarfiksQuatlyLVLName = "Hight";
public int HightGarfiksQuatlyLVLumber = 3;
public string UltraGarfiksQuatlyLVLName = "Ultra";
public int UltraGarfiksQuatlyLVLumber = 4;
/************ AUDIO SETINGS ************/
public string AudioSet = "Audio";
private float VolumeN;
/**********GAMEPLAY SETINGS*********/
public bool GamePlaySettings = true;
public string GamePlaySet = "GamePlay";
public bool Modes = true;
public int Mode = 2;
public string LowModeT = "LowMode";
public string MediumModeT = "MediumMode";
public string HardModeT = "HardMode";
public string ChangeLevelText = "ChangeLevel";
public string Level1 = "SlenderDemo";
public string Level2 = "DefaultDemo";
public string Level3 = "MainDemo";
public string Level1Name = "SlenderDemo";
public string Level2Name = "DefaultDemo";
public string Level3Name = "MainDemo";
public bool GUIScrimmer = true;
/***************** Exit Options ******************/
public string SureExit = "Are you sure?";
public string Yes = "Yes";
public string NO = "No";
/*OTHER*/
private int window;
public string OptionsName = "GameOptions";
public string BackText = "Back";
void Start () {
window = 1;
}
void OnGUI () {
GUI.skin = YourGuiSkin;
GUI.BeginGroup (new Rect (Screen.width / 2 - 100, Screen.height / 2 - 100, 300, 400));
if(window == 1)
{
if(GUI.Button (new Rect (10,30,180,30), PlayButton))
{
window = 2;
}
if(GUI.Button (new Rect (10,70,180,30), OptionsButton))
{
window = 3;
}
if(GUI.Button (new Rect (10,110,180,30), AboutButton))
{
window = 4;
}
if(GUI.Button (new Rect (10,150,180,30), ExitButton))
{
window = 5;
}
}
if(window == 2)
{
GUI.Label(new Rect(50, 10, 180, 30), ChangeLevelText);
if(GUI.Button (new Rect (10,40,180,30), Level1))
{
Application.LoadLevel(Level1Name);
}
if(GUI.Button (new Rect (10,80,180,30), Level2))
{
Application.LoadLevel(Level2Name);
}
if(GUI.Button (new Rect (10,120,180,30), Level3))
{
Application.LoadLevel(Level3Name);
}
if(GUI.Button (new Rect (10,160,180,30), BackText))
{
window = 1;
}
}
if(window == 3)
{
GUI.Label(new Rect(50, 10, 180, 30), OptionsName);
if(GamePlaySettings == true){
if(GUI.Button (new Rect (10,40,180,30), GamePlaySet))
{
window = 6;
}
}
if(GUI.Button (new Rect (10,80,180,30), AudioSet))
{
window = 7;
}
if(GUI.Button (new Rect (10,120,180,30), VideoSet))
{
window = 8;
}
if(GUI.Button (new Rect (10,160,180,30), BackText))
{
window = 1;
}
}
if(window == 4)
{
GUI.Label(new Rect(50, 10, 180, 30), AboutButton);
GUI.Label(new Rect( 10, 40, 180, 40), InfoText);
if(GUI.Button (new Rect (10,170,180,30), BackText))
{
window = 1;
}
}
if(window == 5)
{
GUI.Label(new Rect(50, 10, 180, 30), SureExit);
if(GUI.Button (new Rect (10,40,180,30), Yes))
{
Application.Quit();
}
if(GUI.Button (new Rect (10,80,180,30), NO))
{
window = 1;
}
}
if(window == 8)
{
if(GUI.Button(new Rect (10,80,180,30), LowGarfiksQuatlyLVLName))
{
QualitySettings.SetQualityLevel (LowGarfiksQuatlyLVLumber);
}
if(GUI.Button(new Rect (10,110,180,30), MediumGarfiksQuatlyLVLName))
{
QualitySettings.SetQualityLevel (MediumGarfiksQuatlyLVLumber);
}
if(GUI.Button(new Rect (10,140,180,30), HightGarfiksQuatlyLVLName))
{
QualitySettings.SetQualityLevel (HightGarfiksQuatlyLVLumber);
}
if(GUI.Button(new Rect (10,170,180,30), UltraGarfiksQuatlyLVLName))
{
QualitySettings.SetQualityLevel (UltraGarfiksQuatlyLVLumber);
}
GUI.Label (new Rect (10,50,180,30), QuatlyText);
if(GUI.Button(new Rect (10,210,180,30), BackText))
{
window = 1;
}
}
if(window == 6){
if(PlayerMenu_yes_no == false){
GUIScrimmer = GUI.Toggle (new Rect (10,80,180,30), GUIScrimmer, "GUIScrimmer");
}
if(GUI.Button(new Rect (10,230,180,30), BackText))
{
window = 1;
}
if(Modes == true){
if(GUI.Button(new Rect (10,140,180,30), LowModeT))
{
Mode = 1;
}
if(GUI.Button(new Rect (10,170,180,30), MediumModeT))
{
Mode = 2;
}
if(GUI.Button(new Rect (10,200,180,30), HardModeT))
{
Mode = 3;
}
}
}
if(window == 7){
VolumeN = GUI.HorizontalSlider(new Rect (10,80,180,30), VolumeN, 5, 10);
if(GUI.Button(new Rect (10,210,180,30), BackText))
{
window = 1;
}
}
GUI.EndGroup ();
}
}
ВНИМАНИЕ!
Меню еще не готово!Не сделал вкладки-аудио, ну и настраиваться не полностью...Ну как вам?Надеюсь понравиться . Если хотите могу урок по скриммерам выложить .
Что нового?:
*Упорядочил переменные
*Добавил поддержку GUI Scin
Что в следующих версиях скрипта?:
*Настройки аудио
*Обсалютная настройки из инспектора
*Сохранение сложности
Скриншоты: