Готовый перевод C# Game Programming Cookbook for Unity 3D / Программирование игр на Unity 3D C#. Книга готовых решений.: 10.1.1 Разбор скрипта

Внимание! Этот перевод, возможно, ещё не готов, так как модераторы установили для него статус «идёт перевод»

void Start()
{
// set up default options, if they have been saved out to
// prefs already
if(PlayerPrefs.HasKey(gamePrefsName+"_SFXVol"))
{
audioSFXSliderValue= PlayerPrefs.
GetFloat(gamePrefsName+"_SFXVol"); } else {
audioSFXSliderValue= 1;
}
if(PlayerPrefs.HasKey(gamePrefsName+"_MusicVol"))
{
audioMusicSliderValue= PlayerPrefs.
GetFloat(gamePrefsName+"_MusicVol"); } else {
audioMusicSliderValue= 1;
}
if(PlayerPrefs.HasKey(gamePrefsName+"_GraphicsDetail"))
{
graphicsSliderValue= PlayerPrefs.
GetFloat(gamePrefsName+"_GraphicsDetail"); } else {
string[] names = QualitySettings.names;
detailLevels= names.Length;
graphicsSliderValue= detailLevels;
}
// set the quality setting
QualitySettings.SetQualityLevel( (int)graphicsSliderValue,
true);
}

string[] names = QualitySettings.names;
detailLevels= names.Length;

graphicsSliderValue= detailLevels;

QualitySettings.SetQualityLevel( (int)graphicsSliderValue, true);

void OnGUI()
{ float resX = Screen.width / default_width; float resY = Screen.height / default _height;
GUI.matrix = Matrix4x4.TRS (new Vector3(0, 0, 0),
Quaternion.identity, new Vector3 (resX, resY, 1));

GUI.BeginGroup (new Rect (default _width / 2 - 150, default _height /
2 - 250, 500, 500));

GUI.Label(new Rect( 0, 50, 300, 50 ), gameDisplayName, "textarea");

if(GUI.Button(new Rect( 0, 200, 300, 40 ),"START SINGLE", "button"))

PlayerPrefs.SetInt( "totalPlayers", 1 );
LoadLevel( singleGameStartScene );

if(coopGameStartScene!="")
{
if(GUI.Button(new Rect(0, 250, 300,
40 ),"START CO-OP"))
{
PlayerPrefs.SetInt( "totalPlayers", 2 );
LoadLevel( coopGameStartScene );
}
if(GUI.Button(new Rect(0, 300, 300, 40 ),"OPTIONS"))
{
ShowOptionsMenu();
}
} else {
if(GUI.Button(new Rect(0, 250, 300, 40 ),"OPTIONS"))
{
ShowOptionsMenu();
}
}

if(GUI.Button(new Rect(0, 400, 300, 40),"EXIT"))
{
ConfirmExitGame();
}
// End the group we started above. This is very
// important to remember!
GUI.EndGroup ();
break;

case 1:
// Options menu
GUI.BeginGroup (new Rect (native_width / 2 - 150,
native_height / 2 - 250, 500, 500));
// Are you sure you want to exit?
GUI.Label(new Rect(0, 50, 300, 50), "OPTIONS",
"textarea");
if(GUI.Button(new Rect(0, 250, 300, 40 ),"AUDIO OPTIONS"))
{
ShowAudioOptionsMenu();
}
if(GUI.Button(new Rect(0, 300, 300, 40),"GRAPHICS
OPTIONS"))
{
ShowGraphicsOptionsMenu();
}
if(GUI.Button(new Rect(0, 400, 300, 40),"BACK TO
MAIN MENU"))
{
GoMainMenu();
}
GUI.EndGroup ();

case 2:
GUI.BeginGroup (new Rect (default_width / 2 - 150,
default_height / 2 - 250, 500, 500));
// Are you sure you want to exit?
GUI.Label(new Rect(0, 50, 300, 50), "Are you sure
you want to exit?", "textarea");
if(GUI.Button(new Rect(0, 250, 300, 40),"YES, QUIT
PLEASE!"))
{
ExitGame();
}
if(GUI.Button(new Rect(0, 300, 300, 40),"NO, DON’T
QUIT"))
{
GoMainMenu();
}
GUI.EndGroup ();
break;

case 3:
// AUDIO OPTIONS
GUI.BeginGroup (new Rect (default_width / 2 - 150,
default_height / 2 - 250, 500, 500));
GUI.Label(new Rect(0, 50, 300, 50), "AUDIO OPTIONS",
"textarea");
GUI.Label(new Rect(0, 170, 300, 20), "SFX volume:");

audioSFXSliderValue = GUI.HorizontalSlider (new Rect( 0, 200, 300, 50 ),
audioSFXSliderValue, 0.0f, 1f);

Внимание! Этот перевод, возможно, ещё не готов.
Его статус: идёт перевод

Переведено на Нотабеноиде
http://notabenoid.org/book/55263/242534

Переводчики: ilia1395

Настройки

Готово:

18.98% КП = 1.0

Непереведённые фрагменты будут пропущены.