Beispiel #1
0
    public void Apply()
    {
        // Resolution
        Resolution     resolution = Screen.resolutions[resolutionDropdown.value];
        FullScreenMode fsm        = (FullScreenMode)fullscreenDropdown.value;

        SettingsManager.settingsData.width          = resolution.width;
        SettingsManager.settingsData.height         = resolution.height;
        SettingsManager.settingsData.fullScreenMode = fullscreenDropdown.value;

        Debug.Log(resolution.ToString());
        Debug.Log(fsm);

        Screen.SetResolution(resolution.width, resolution.height, fsm);

        // Shadow Quality
        SettingsManager.settingsData.shadowQuality = shadowQualityDropdown.value;
        ShadowQuality sq = (ShadowQuality)shadowQualityDropdown.value;

        Debug.Log(sq);
        QualitySettings.shadows = sq;

        // Shadow Distance
        QualitySettings.shadowDistance = SettingsManager.settingsData.shadowDistance;

        // Anisotropic Filtering
        SettingsManager.settingsData.anisotropicFiltering = anisotropicFilteringDropdown.value;
        AnisotropicFiltering af = (AnisotropicFiltering)anisotropicFilteringDropdown.value;

        Debug.Log(af);
        QualitySettings.anisotropicFiltering = af;

        // Anti-Aliasing
        QualitySettings.antiAliasing = SettingsManager.settingsData.antiAliasing;
    }
Beispiel #2
0
        private void SetupProjectParameters()
        {
            EditorApplication.LockReloadAssemblies();

            m_EditorBuildSettings = EditorBuildSettings.scenes;

#pragma warning disable 618
            m_DisplayResolutionDialog = PlayerSettings.displayResolutionDialog;
            PlayerSettings.displayResolutionDialog = ResolutionDialogSetting.Disabled;
#pragma warning restore 618

            m_RunInBackground = PlayerSettings.runInBackground;
            PlayerSettings.runInBackground = true;

            m_FullScreenMode = PlayerSettings.fullScreenMode;
            PlayerSettings.fullScreenMode = FullScreenMode.Windowed;

            m_OldAotOptions           = PlayerSettings.aotOptions;
            PlayerSettings.aotOptions = "nimt-trampolines=1024";

            m_ResizableWindow = PlayerSettings.resizableWindow;
            PlayerSettings.resizableWindow = true;

            m_ShowUnitySplashScreen          = PlayerSettings.SplashScreen.show;
            PlayerSettings.SplashScreen.show = false;

#pragma warning disable 618
            m_OldLightmapping           = Lightmapping.giWorkflowMode;
            Lightmapping.giWorkflowMode = Lightmapping.GIWorkflowMode.OnDemand;
#pragma warning restore 618

            m_explicitNullChecks = EditorUserBuildSettings.explicitNullChecks;
            EditorUserBuildSettings.explicitNullChecks = true;
        }
Beispiel #3
0
    public Options()
    {
        version = kVersion;

        width          = 0;
        height         = 0;
        refreshRate    = 0;
        fullScreenMode = FullScreenMode.ExclusiveFullScreen;
        vSync          = false;

        masterVolume   = 1f;
        musicVolume    = 0.8f;
        keysoundVolume = 1f;
        sfxVolume      = 1f;
        // Cannot call GetDefaultAudioBufferSize() here, because
        // somehow Unity calls this constructor during serialization,
        // and calling AudioSettings.GetConfiguration() at that time
        // causes an exception.
        audioBufferSize = 512;

        touchOffsetMs          = 0;
        touchLatencyMs         = 0;
        keyboardMouseOffsetMs  = 0;
        keyboardMouseLatencyMs = 0;
    }
        protected override void ProcessSaveVersion()
        {
            var saveData = GetSelfData();

            if (saveData.saveVersion != SAVE_VERSION)
            {
                if (string.IsNullOrEmpty(saveData.saveVersion))
                {
                    saveData.saveVersion = "0";
                }

                var versionNumbers = saveData.saveVersion.Split('.').Select(v =>
                {
                    var success = int.TryParse(v, out var result);
                    if (!success)
                    {
                        throw new ArgumentException("Invalid Save Version, cannot parse");
                    }

                    return(result);
                }).ToList();

                if (VersionSmallerThan("1.0", versionNumbers))
                {
                    width           = Screen.currentResolution.width;
                    height          = Screen.currentResolution.height;
                    fullScreenMode  = Screen.fullScreenMode;
                    targetFrameRate = Application.targetFrameRate;
                }

                Save(false);
            }
        }
Beispiel #5
0
    public void SetFullscreenMode(int index)
    {
        string text = GameObject.Find("FullscreenMode").GetComponent <TMP_Dropdown>().options[index].text.ToLower();

        switch (text)
        {
        case "fullscreen":
            tempMode = FullScreenMode.ExclusiveFullScreen;
            break;

        case "borderless":
            tempMode = FullScreenMode.FullScreenWindow;
            break;

        case "windowed":
            tempMode = FullScreenMode.Windowed;
            break;

        default:
            Debug.LogError("Given FullscreenMode does not exist.");
            break;
        }

        GameManager.instance.changesSaved = false;
    }
Beispiel #6
0
    // Start is called before the first frame update
    void Start()
    {
        HashSet <Resolution> filteredResolutions = new HashSet <Resolution>();

        resolutions = Screen.resolutions;

        for (int i = 0; i < resolutions.Length; i++)
        {
            filteredResolutions.Add(resolutions[i]);
        }

        filteredResolutions.RemoveWhere(IsUnsuitableRefreshFrame);
        filteredResolutions.RemoveWhere(IsUnsuitableResolution);

        resolutions = new Resolution[filteredResolutions.Count];
        filteredResolutions.CopyTo(resolutions);

        // Get current resolution from PlayerPrefs
        currentResolutionIndex = PlayerPrefs.GetInt(RESOLUTION_PREF_KEY, 0);

        Resolution currentResolution = resolutions[currentResolutionIndex];

        SetResolutionText(currentResolution);

        // Get current screen mode from PlayerPrefs
        fullscreenToggler.isOn = PlayerPrefs.GetInt(FULLSCREENMODE_PREF_KEY, 0) == 1;

        FullScreenMode fullScreenMode = fullscreenToggler.isOn ? FullScreenMode.FullScreenWindow : FullScreenMode.Windowed;

        Screen.SetResolution(currentResolution.width, currentResolution.height, fullScreenMode);
    }
Beispiel #7
0
        public void Apply()
        {
            Screen.orientation = (ScreenOrientation)(screenOrientation.value + 1);
            FullScreenMode fullScreenMode = (FullScreenMode)this.fullScreenMode.value;
            int            refreshRate    = 30;

            switch (this.refreshRate.value)
            {
            case 0:
                refreshRate = 30;
                break;

            case 1:
                refreshRate = 60;
                break;

            case 2:
                refreshRate = 90;
                break;

            case 3:
                refreshRate = 120;
                break;

            default:
                refreshRate = 30;
                break;
            }
            Screen.SetResolution(int.Parse(screenSizeX.text), int.Parse(screenSizeY.text), fullScreenMode, refreshRate);
        }
    /// <summary>
    /// Initialize UI to stored video settings.
    /// </summary>
    public void InitVideoSettings()
    {
        // Create PlayerPrefs if they don't exist
        if (!PlayerPrefs.HasKey(graphicsQualityName))
        {
            PlayerPrefs.SetInt(graphicsQualityName, 4);
            PlayerPrefs.SetInt(fullscreenModeName, (int)FullScreenMode.Windowed);
            PlayerPrefs.SetInt(screenResolutionName, 3);
            PlayerPrefs.Save();
        }

        // Init graphics quality
        qualityLevel = PlayerPrefs.GetInt(graphicsQualityName, 0);
        qualityLevel = Mathf.Clamp(qualityLevel, 0, QualitySettings.names.Length - 1);
        graphicsQualityLabel.text = QualitySettings.names[qualityLevel];
        QualitySettings.SetQualityLevel(qualityLevel, true);

        // Init resolution and fullscreen modes
        fullscreenMode  = (FullScreenMode)PlayerPrefs.GetInt(fullscreenModeName, (int)FullScreenMode.Windowed);
        resolutionIndex = PlayerPrefs.GetInt(screenResolutionName, 3);
        resolutionIndex = Mathf.Clamp(resolutionIndex, 0, supportedResolutions.Length - 1);

        resolutionLabel.text = supportedResolutions[resolutionIndex].x.ToString() + "x" + supportedResolutions[resolutionIndex].y.ToString();
        fullscreenLabel.text = fullscreenMode.ToString();
        Screen.SetResolution(supportedResolutions[resolutionIndex].x, supportedResolutions[resolutionIndex].y, fullscreenMode);
    }
    public void SetFullScreenMode(FullScreenMode mode)
    {
        if (Screen.fullScreenMode != mode)
        {
            Screen.SetResolution(SaveManager.instance.CurrentOptions.CurrentResolution.width, SaveManager.instance.CurrentOptions.CurrentResolution.height, mode);

            switch (mode)
            {
            case FullScreenMode.ExclusiveFullScreen:
                Screen.fullScreen = true;
                break;

            case FullScreenMode.FullScreenWindow:
                Screen.fullScreen = true;
                break;

            case FullScreenMode.MaximizedWindow:
                Screen.fullScreen = false;
                break;

            case FullScreenMode.Windowed:
                Screen.fullScreen = false;
                break;
            }

            Options currentOptions = SaveManager.instance.CurrentOptions;
            currentOptions.ScreenMode = mode;
            SaveManager.instance.SaveOptions(currentOptions);

            AudioManager.instance.PlayButtonClick();
        }
    }
        /**
         * Initialize the dropdown options.
         */
        private void InitializeOptions(Dropdown dropdown)
        {
            FullScreenMode mode = preferences.GetFullScreenMode();

            dropdown.value = Array.IndexOf(modes, mode);
            dropdown.onValueChanged.AddListener(OnDropdownValueChanged);
        }
        internal void SaveSettings()
        {
            XmlTextWriter textWriter = new XmlTextWriter(Program.formMain.dirResources + "Settings.xml", Encoding.UTF8);

            textWriter.WriteStartDocument();
            textWriter.Formatting = Formatting.Indented;

            textWriter.WriteStartElement("Settings");

            // Записываем информацию о настройках игры
            textWriter.WriteStartElement("Game");
            textWriter.WriteElementString("ShowSplashVideo", ShowSplashVideo.ToString());
            textWriter.WriteElementString("FullScreenMode", FullScreenMode.ToString());
            textWriter.WriteElementString("CheckUpdatesOnStartup", CheckUpdateOnStartup.ToString());
            textWriter.WriteEndElement();

            textWriter.WriteStartElement("Battlefield");
            textWriter.WriteElementString("ShowPath", BattlefieldShowPath.ToString());
            textWriter.WriteElementString("ShowGrid", BattlefieldShowGrid.ToString());
            textWriter.WriteEndElement();

            textWriter.WriteStartElement("Player");
            textWriter.WriteElementString("Name", NamePlayer);
            textWriter.WriteElementString("IndexAvatar", IndexInternalAvatar.ToString());
            textWriter.WriteElementString("FileNameAvatar", FileNameAvatar);
            textWriter.WriteElementString("DirectoryAvatar", DirectoryAvatar);
            textWriter.WriteEndElement();

            textWriter.WriteEndElement();
            textWriter.Close();
            textWriter.Dispose();
        }
Beispiel #12
0
 public static void SaveSettings()
 {
     if (resolutionCurrent != resolutionSave || screenmodeSave != screenmodeCurrent)
     {
         screenmodeCurrent = screenmodeSave;
         FullScreenMode mode = StringToScreenMode(screenmodeCurrent);
         SetResolution(ResolutionToVector(resolutionSave), mode);
         resolutionCurrent = resolutionSave;
     }
     lightingCurrent = lightingSave;
     PlayerPrefs.SetString("lighting", lightingCurrent);
     for (int i = 0; i < saves.Length; i++)
     {
         if (saves[i].Name.Contains("volume"))
         {
             var save    = saves[i].GetValue(null);
             var current = currents[i].GetValue(null);
             if (save != current)
             {
                 var name = saves[i].Name.Substring(0, saves[i].Name.Length - 4);
                 currents[i].SetValue(null, save);
                 PlayerPrefs.SetString(name, save.ToString());
                 Audio.instance.VolumeReset(name, Int32.Parse(save.ToString()));
             }
         }
     }
 }
 public void ApplyResolution(int p_width, int p_height, FullScreenMode p_fullscreen, int p_refreshRate)
 {
     Screen.SetResolution(p_width,
                          p_height,
                          p_fullscreen,
                          p_refreshRate);
 }
 void SetResolution(int width, int height, FullScreenMode mode, int hz)
 {
     // prevent setting resolution multiple times when dialog is updated in the next frame
     //Debug.LogError("DESIRED res: " + GetResolutionString(width, height) + " @ " + hz + " Hz in " + mode);
     Screen.SetResolution(width, height, mode, hz);
     QualitySettings.vSyncCount = vSync.value; // reset vsync setting as it may be affected by resolution
 }
Beispiel #15
0
    void UpdateSpinner(Scrollbar Scroll)
    {
        if (MenuCon == null)
        {
            MenuCon = FindObjectOfType <MenuNavigator>();
        }
        if (MenuCon != null)
        {
            int    Value = (int)(Scroll.value * (Scroll.numberOfSteps - 1));
            string Text;

            Debug.Log(Value + " | " + Scroll.value + " | " + Scroll.numberOfSteps + " | " + Screen.resolutions.Length);
            switch (SettingsTarget)
            {
            case SettingsNames.GFX_RES:
                //UpdateSpinner(Scroll, Screen.resolutions[Value]);
                Resolution Res = Screen.resolutions[Value];
                Text = (Res.width + "x" + Res.height);
                UpdateText(Text);
                MenuCon.SaveToVar(SettingsTarget, Value);
                break;

            case SettingsNames.GFX_FULLSCREEN:
                FullScreenMode FSMode = (FullScreenMode)Value;
                //UpdateSpinner(Scroll, FSMode);
                Text = FSMode.ToString();
                UpdateText(Text);
                MenuCon.SaveToVar(SettingsTarget, Value);
                break;

            default:
                break;
            }
        }
    }
Beispiel #16
0
    public void LoadFromPrefs()
    {
        int value = PlayerPrefs.GetInt(label, 0);

        toSet          = (FullScreenMode)value;
        dropdown.value = value;
    }
Beispiel #17
0
        /// <summary>
        /// Deserialize
        /// </summary>
        /// <param name="binaryReader">BinaryReader</param>
        public virtual void Deserialize(BinaryReader binaryReader)
        {
            m_currentResolutionWidth       = binaryReader.ReadInt32();
            m_currentResolutionHeight      = binaryReader.ReadInt32();
            m_currentResolutionRefreshRate = binaryReader.ReadInt32();
            m_width                          = binaryReader.ReadInt32();
            m_height                         = binaryReader.ReadInt32();
            m_sleepTimeout                   = binaryReader.ReadInt32();
            m_preferredRefreshRate           = binaryReader.ReadInt32();
            m_autorotateToLandscapeLeft      = binaryReader.ReadBoolean();
            m_autorotateToLandscapeRight     = binaryReader.ReadBoolean();
            m_autorotateToPortrait           = binaryReader.ReadBoolean();
            m_autorotateToPortraitUpsideDown = binaryReader.ReadBoolean();
            m_fullScreen                     = binaryReader.ReadBoolean();
#if UNITY_2019_1_OR_NEWER
            m_brightness = binaryReader.ReadSingle();
#endif
            m_dpi            = binaryReader.ReadSingle();
            m_fullScreenMode = (FullScreenMode)binaryReader.ReadInt32();
            m_orientation    = (ScreenOrientation)binaryReader.ReadInt32();
            m_safeArea       = SerializerKun.DesirializeObject <RectKun>(binaryReader);
#if UNITY_2019_1_OR_NEWER
            m_cutouts = SerializerKun.DesirializeObjects <RectKun>(binaryReader);
#endif
            m_resolutions = SerializerKun.DesirializeObjects <ResolutionKun>(binaryReader);
        }
Beispiel #18
0
    void ApplyGraphicSettings()
    {
        ScreenResolution res            = SettingsManager.Instance.Settings.GraphicSettings.resolution;
        FullScreenMode   fullScreenMode = SettingsManager.Instance.Settings.GraphicSettings.fullScreenMode;

        Screen.SetResolution(res.Width, res.Height, fullScreenMode, res.RefreshRate);
    }
Beispiel #19
0
    public IEnumerator GetUIValues(Action <GameSettings> func)
    {
        GameSettings settings = new GameSettings();

        //VIDEO
        settings.resolution = new ResolutionSerializable();
        if (resolution.GetCurrentOption() == "AUTO")
        {
            FullScreenMode prev = Screen.fullScreenMode;
            Screen.fullScreenMode = FullScreenMode.Windowed;
            yield return(0);

            settings.resolution.width  = Screen.currentResolution.width;
            settings.resolution.height = Screen.currentResolution.height;
            Screen.fullScreenMode      = prev;
        }
        else
        {
            settings.resolution.width  = int.Parse(resolution.GetCurrentOption().Split(new string[] { " x " }, StringSplitOptions.None)[0]);
            settings.resolution.height = int.Parse(resolution.GetCurrentOption().Split(new string[] { " x " }, StringSplitOptions.None)[1]);
        }
        settings.window_mode     = (window_mode.currentOption == 0)? FullScreenMode.FullScreenWindow : ((window_mode.currentOption == 1)? FullScreenMode.MaximizedWindow : FullScreenMode.Windowed);
        settings.graphic_quality = graphic_quality.currentOption;

        //AUDIO
        settings.volume = volume.GetStep() / 10f;

        func(settings);
    }
Beispiel #20
0
    private FullScreenMode GetSelectedFullScreenMode()
    {
        string         selectedOption = screenModeDropdown.options[screenModeDropdown.value].text;
        FullScreenMode mode           = stringToModeMapping[selectedOption];

        return(mode);
    }
    // public methods

    public void SetFullscreen(int newFullscreenIndex)
    {
        FullScreenMode mode;

        switch (newFullscreenIndex)
        {
        case 0:
            mode = FullScreenMode.FullScreenWindow;
            break;

        case 1:
            mode = FullScreenMode.MaximizedWindow;
            break;

        case 2:
            mode = FullScreenMode.ExclusiveFullScreen;
            break;

        case 3:
            mode = FullScreenMode.Windowed;
            break;

        default:
            Debug.LogError("Reached Unexpected default case");
            return;
        }
        Screen.fullScreenMode = mode;
        GlobalSettings.globalFullscreenIndex = newFullscreenIndex;
        GlobalSettings.globalFullscreenMode  = mode;
    }
    public override void OnShow()
    {
        base.OnShow();
        this.FillAvailableResolutions();
        this.m_Quality.SetByOption(QualitySettings.names[QualitySettings.GetQualityLevel()]);
        Resolution resolution = ResolutionExtension.SelectResolution((Screen.fullScreenMode == FullScreenMode.Windowed) ? ResolutionExtension.ResolutionFromString(GreenHellGame.Instance.m_Settings.m_Resolution) : Screen.currentResolution);
        string     byOption;
        string     text;

        resolution.ToString2(out byOption, out text);
        if (!this.m_Resolution.SetByOption(byOption))
        {
            Screen.currentResolution.ToString2(out byOption, out text);
            this.m_Resolution.SetByOption(byOption);
        }
        FullScreenMode fullScreenMode = Screen.fullScreenMode;

        this.m_Fullscreen.SetSelectedOptionEnumValue <FullScreenMode>(fullScreenMode);
        this.FillAvailableRefreshRate(resolution);
        this.m_VSync.SetSelectedOptionBoolValue(QualitySettings.vSyncCount != 0);
        this.m_ShadowDistance.value = GreenHellGame.Instance.m_Settings.m_ShadowDistance;
        this.m_AntiAliasing.SetSelectedOptionBoolValue(GreenHellGame.Instance.m_Settings.m_AntiAliasing);
        this.m_TextureQuality.SetByOption(GreenHellGame.Instance.m_Settings.m_TextureQuality);
        this.m_FOV.value = GreenHellGame.Instance.m_Settings.m_FOVChange;
        this.m_ObjectDrawDistance.value = GreenHellGame.Instance.m_Settings.m_ObjectDrawDistance;
        this.m_FovTitlePrefix           = GreenHellGame.Instance.GetLocalization().Get("MenuOptions_Graphics_FOV", true);
        this.OnSliderMoved(this.m_FOV);
        this.m_Brightness.value = GreenHellGame.Instance.m_Settings.m_BrightnessMul;
    }
Beispiel #23
0
            // Token: 0x06001939 RID: 6457 RVA: 0x0006CEAC File Offset: 0x0006B0AC
            public override void SetString(string newValue)
            {
                try
                {
                    FullScreenMode fullScreenMode = FullScreenMode.ExclusiveFullScreen;
                    switch ((SettingsConVars.WindowModeConVar.WindowMode)Enum.Parse(typeof(SettingsConVars.WindowModeConVar.WindowMode), newValue, true))
                    {
                    case SettingsConVars.WindowModeConVar.WindowMode.Fullscreen:
                        fullScreenMode = FullScreenMode.FullScreenWindow;
                        break;

                    case SettingsConVars.WindowModeConVar.WindowMode.Window:
                        fullScreenMode = FullScreenMode.Windowed;
                        break;

                    case SettingsConVars.WindowModeConVar.WindowMode.FullscreenExclusive:
                        fullScreenMode = FullScreenMode.ExclusiveFullScreen;
                        break;
                    }
                    Screen.fullScreenMode = fullScreenMode;
                }
                catch (ArgumentException)
                {
                    Console.ShowHelpText(this.name);
                }
            }
Beispiel #24
0
 public Options(Options options)
 {
     fullscreenMode = options.fullscreenMode;
     gridThickness  = options.gridThickness;
     bloom          = options.bloom;
     lensDistortion = options.lensDistortion;
     colorPalette   = options.colorPalette;
 }
Beispiel #25
0
    public void AlterFullScreen()
    {
        FullScreenMode value = (FullScreenMode)FullScreenDropdown.value;

        Screen.fullScreenMode = value;
        Screen.fullScreen     = value != FullScreenMode.Windowed && value != FullScreenMode.MaximizedWindow;
        GD.fullScreen         = value;
    }
Beispiel #26
0
    private void OnEnable()
    {
        startingWidth      = Screen.currentResolution.width;
        startingHeight     = Screen.currentResolution.height;
        startingScreenMode = Screen.fullScreenMode;

        Screen.SetResolution(1920, 1080, FullScreenMode.Windowed);
    }
Beispiel #27
0
 public Options(FullScreenMode fullscreenMode, float gridThickness, float bloom, float lensDistortion, int colorPalette)
 {
     this.fullscreenMode = fullscreenMode;
     this.gridThickness  = gridThickness;
     this.bloom          = bloom;
     this.lensDistortion = lensDistortion;
     this.colorPalette   = colorPalette;
 }
Beispiel #28
0
        public static void SetResolution(int width, int height, FullScreenMode fullScreenMode, int preferredRefreshRate)
        {
            Screen.SetResolution(width, height, fullScreenMode, preferredRefreshRate);

            resolution = new Vector2Int(width, height);

            UpdateScreenSize(resolution);
        }
Beispiel #29
0
        public void Apply(FullScreenMode fullscreenMode)
        {
#if !UNITY_EDITOR
            UnityEngine.Assertions.Assert.IsTrue(IsSupported());
#endif
            Screen.SetResolution(_width, _height, fullscreenMode, _refreshRate);
            Canvas.ForceUpdateCanvases();
        }
        /// <summary>
        /// Called when [full screen changed].
        /// </summary>
        /// <param name="mode">The <see cref="FullScreenMode"/>.</param>
        private void OnFullScreenChanged(FullScreenMode mode)
        {
            EventHandler <FullScreenModeEventArgs> fullScreenChangedHandler = this.FullScreenChanged;

            if (fullScreenChangedHandler != null)
            {
                fullScreenChangedHandler(this, new FullScreenModeEventArgs(mode));
            }
        }
Beispiel #31
0
 public void DisableFullScreen( float newScale )
 {
     Graphics.IsFullScreen = false;
     fullScreenMode = FullScreenMode.Windowed;
     Scale = newScale;
 }
Beispiel #32
0
 public void EnableFullScreen( FullScreenMode newMode = FullScreenMode.LargestScale )
 {
     FullScreenMode = newMode;
 }