Beispiel #1
0
    private void Awake()
    {
        audioSource = this.GetComponent <AudioSource>();
        if (Time.timeScale > 0.01f)
        {
            /*fader = this.GetComponent<UIFader>();
             * if(fader)
             *  fader.FadeIn();
             * fillBackground.color = Color.clear;*/
        }
        else
        {
            this.GetComponent <CanvasGroup>().alpha = 1f;
        }

        if (Screen.fullScreen)
        {
            fullScreenToggle.Check();
        }
        else
        {
            fullScreenToggle.Uncheck();
        }

        //SOUND SLIDERS INITIALIZATION
        float value;

        audioMixer.GetFloat("GlobalVolume", out value);
        VolumeSlider.value = value;
        VolumeSlider.Refresh();

        audioMixer.GetFloat("MusicVolume", out value);
        MusicVolumeSlider.value = value;
        MusicVolumeSlider.Refresh();

        audioMixer.GetFloat("SoundVolume", out value);
        SoundVolumeSlider.value = value;
        SoundVolumeSlider.Refresh();


        qualityDropdown.value = QualitySettings.GetQualityLevel();

        resolutions = Screen.resolutions;
        resolutionDropdown.ClearOptions();

        List <string> options = new List <string>();

        int currentResolutionIndex = 0;

        for (int i = 0; i < resolutions.Length; i++)
        {
            string option = resolutions[i].width + " x " + resolutions[i].height;
            options.Add(option);
            if (resolutions[i].width == Screen.currentResolution.width && resolutions[i].height == Screen.currentResolution.height)
            {
                currentResolutionIndex = i;
            }
        }
        resolutionDropdown.AddOptions(options);
        resolutionDropdown.value = currentResolutionIndex;
        resolutionDropdown.RefreshShownValue();
        GameObject.FindGameObjectsWithTag("InputHandler")[0].GetComponent <InputHandler>().addObserver(this);
    }