コード例 #1
0
    public static void Aplysettings(GameSettinngs gameSettinngs)
    {
        try
        {
            Screen.SetResolution(Resolutions[gameSettinngs.resolutionIndex].width, Resolutions[gameSettinngs.resolutionIndex].height, Screen.fullScreen);
        }
        catch (Exception)
        {
            gameSettinngs.resolutionIndex = 0;
            Screen.SetResolution(Resolutions[gameSettinngs.resolutionIndex].width, Resolutions[gameSettinngs.resolutionIndex].height, Screen.fullScreen);
        }
        Screen.fullScreen = gameSettinngs.fullScreen;
        QualitySettings.masterTextureLimit = gameSettinngs.quality;
        QualitySettings.antiAliasing       = (int)Mathf.Pow(2, gameSettinngs.antialiasing);
        QualitySettings.vSyncCount         = gameSettinngs.vSync;

        GameSettinngs = gameSettinngs;
    }
コード例 #2
0
    public static void LoadSettings()
    {
        GameSettinngs gameSettinngs;

        if (File.Exists(Application.persistentDataPath + "/gamesettings.json"))
        {
            gameSettinngs = JsonUtility.FromJson <GameSettinngs>(File.ReadAllText(Application.persistentDataPath + "/gamesettings.json"));
        }
        else
        {
            gameSettinngs = new GameSettinngs
            {
                mouseSensitivity = 0.5f,
                audioVolume      = 1f
            };
            SaveSettings(gameSettinngs);
        }

        Aplysettings(gameSettinngs);
    }
コード例 #3
0
    void OnEnable()
    {
        _gameSettinngs = SettingManager.GameSettinngs ?? new GameSettinngs();

        if (FullscreenToggle && ResolutionDropdown && QualityDropdown && AntialiasingDropdown && VSyncDropdown && AudioVolumeSlider && MouseSensitivitySlider && ApplyButton)
        {
            FullscreenToggle.onValueChanged.AddListener(delegate { OnFullscreenToggle(); });
            ResolutionDropdown.onValueChanged.AddListener(delegate { OnResolutionChange(); });
            QualityDropdown.onValueChanged.AddListener(delegate { OnQualityChange(); });
            AntialiasingDropdown.onValueChanged.AddListener(delegate { OnAntialiasingChange(); });
            VSyncDropdown.onValueChanged.AddListener(delegate { OnVsyncChange(); });
            AudioVolumeSlider.onValueChanged.AddListener(delegate { OnAudioVolumeChange(); });
            MouseSensitivitySlider.onValueChanged.AddListener(delegate { OnSensitivitChange(); });
            ApplyButton.onClick.AddListener(OnApplyButtonClick);
        }

        _resolutions = SettingManager.Resolutions;
        foreach (var resolution in _resolutions)
        {
            ResolutionDropdown.options.Add(new Dropdown.OptionData(resolution.ToString()));
        }

        LoadInputs();
    }
コード例 #4
0
    public static void SaveSettings(GameSettinngs gameSettinngs)
    {
        var jsonData = JsonUtility.ToJson(gameSettinngs, true);

        File.WriteAllText(Application.persistentDataPath + "/gamesettings.json", jsonData);
    }