Exemple #1
0
    void PauseMenu()
    {
        GUIStyle style = new GUIStyle();

        style.alignment = TextAnchor.UpperCenter;

        int startX = Screen.width / 2 - 70;
        int startY = Screen.height / 2 - 200;
        int width = 120; int height = 25; int spaceY = 30;

        for (int i = 0; i < 3; i++)
        {
            GUI.Box(new Rect(startX, startY, 140, boxHeight), "");
        }

        style.fontSize = 20;      style.fontStyle = FontStyle.Bold; style.normal.textColor = UI.colorH;
        GUI.Label(new Rect(startX + 5, startY += 5, width, height), "Paused", style);

        startX += 10;     startY += 20;

        GUI.changed = false;

        GUIStyle style2 = new GUIStyle("Label");

        style2.alignment = TextAnchor.UpperCenter;

        //~ float musicVol=AudioManager.GetMusicVolume();
        //~ float sfxVol=AudioManager.GetSFXVolume();

        GUI.Label(new Rect(startX, startY += 35, width, 30), "Music Volume: " + ((musicVol * 100).ToString("f0")) + "%", style2);
        musicVol = GUI.HorizontalSlider(new Rect(startX, startY += 20, width, height), musicVol, 0.0F, 1.0F);
        GUI.Label(new Rect(startX, startY += 35, width, 30), "SFX Volume: " + ((sfxVol * 100).ToString("f0")) + "%", style2);
        sfxVol = GUI.HorizontalSlider(new Rect(startX, startY += 20, width, height), sfxVol, 0.0F, 1.0F);

        if (GUI.changed)
        {
            AudioManager.SetSFXVolume(sfxVol);
            AudioManager.SetMusicVolume(musicVol);
        }

        if (GUI.Button(new Rect(startX, startY += spaceY, width, height), "Resume", buttonStyleAlt))
        {
            TogglePause();
        }
        if (GUI.Button(new Rect(startX, startY += spaceY, width, height), "Restart", buttonStyleAlt))
        {
            Time.timeScale = 1;
            Application.LoadLevel(Application.loadedLevelName);
        }
        if (GUI.Button(new Rect(startX, startY += spaceY, width, height), "MainMenu", buttonStyleAlt))
        {
            Time.timeScale = 1;
            GameControlTB.LoadMainMenu();
        }


        startY   += spaceY + 5;
        boxHeight = startY - (Screen.height / 2 - 200);
    }