LoadGameSettings() public method

Read the game settings from the file
public LoadGameSettings ( ) : void
return void
Ejemplo n.º 1
0
        /*
         * //Color fade duration value
         * //public float crossFadeDuration;
         * //custom color
         * //public Color _customColor;
         *
         * //Animation clips
         * private AnimationClip audioIn;
         * private AnimationClip audioOut;
         * public AnimationClip vidIn;
         * public AnimationClip vidOut;
         * public AnimationClip mainIn;
         * public AnimationClip mainOut;
         */
        //Blur Variables
        //Blur Effect Script (using the standard image effects package)
        //public Blur blurEffect;
        //Blur Effect Shader (should be the one that came with the package)
        //public Shader blurEffectShader;
        //Boolean for if the blur effect was originally enabled
        //public Boolean blurBool;

        /// <summary>
        /// The start method; you will need to place all of your inital value getting/setting here.
        /// </summary>
        public void Start()
        {
            readUseSimpleTerrain = useSimpleTerrain;
            if (useSimpleTerrain)
            {
                readSimpleTerrain = simpleTerrain;
            }
            else
            {
                readTerrain = terrain;
            }

            mainCamShared = mainCam;
            //Set the lastmusicmult and last audiomult
            lastMusicMult = audioMusicSlider.value;
            lastAudioMult = audioEffectsSlider.value;
            //Set the first selected item
            uiEventSystem.firstSelectedGameObject = defualtSelectedMain;
            //Get the presets from the quality settings
            presets          = QualitySettings.names;
            presetLabel.text = presets[QualitySettings.GetQualityLevel()].ToString();
            _currentLevel    = QualitySettings.GetQualityLevel();
            //Get the current resoultion, if the game is in fullscreen, and set the label to the original resolution
            allRes     = Screen.resolutions;
            currentRes = Screen.currentResolution;
            //Debug.Log("ini res" + currentRes);
            resolutionLabel.text = Screen.currentResolution.width.ToString() + " x " + Screen.currentResolution.height.ToString();
            isFullscreen         = Screen.fullScreen;
            //get initial screen effect bools
            lastAOBool  = aoToggle.isOn;
            lastDOFBool = dofToggle.isOn;
            //get all specified audio source volumes
            _beforeEffectVol = new float[_audioEffectAmt];
            beforeMaster     = AudioListener.volume;
            //get all ini values
            aaQualINI     = QualitySettings.antiAliasing;
            renderDistINI = mainCam.farClipPlane;
            shadowDistINI = QualitySettings.shadowDistance;
            fovINI        = mainCam.fieldOfView;
            msaaINI       = QualitySettings.antiAliasing;
            vsyncINI      = QualitySettings.vSyncCount;
            //enable titles
            TitleTexts.SetActive(true);
            //Find terrain
            terrain = Terrain.activeTerrain;
            //Disable other panels
            //mainPanel.SetActive(false);
            vidPanel.SetActive(false);
            audioPanel.SetActive(false);
            //Enable mask
            //mask.SetActive(false);
            //set last texture limit
            lastTexLimit = QualitySettings.masterTextureLimit;
            //set last shadow cascade
            lastShadowCascade = QualitySettings.shadowCascades;
            saveSettings.LoadGameSettings(File.ReadAllText(Application.persistentDataPath + "/" + saveSettings.fileName));
            try
            {
                densityINI = Terrain.activeTerrain.detailObjectDensity;
            }
            catch
            {
            }

            //set the blur boolean to false;
            //blurBool = false;
            //Add the blur effect

            /*mainCamObj.AddComponent(typeof(Blur));
             * blurEffect = (Blur)mainCamObj.GetComponent(typeof(Blur));
             * blurEffect.blurShader = blurEffectShader;
             * blurEffect.enabled = false;  */
        }
        /*
         * //Color fade duration value
         * //public float crossFadeDuration;
         * //custom color
         * //public Color _customColor;
         *
         * //Animation clips
         * private AnimationClip audioIn;
         * private AnimationClip audioOut;
         * public AnimationClip vidIn;
         * public AnimationClip vidOut;
         * public AnimationClip mainIn;
         * public AnimationClip mainOut;
         */
        //Blur Variables
        //Blur Effect Script (using the standard image effects package)
        //public Blur blurEffect;
        //Blur Effect Shader (should be the one that came with the package)
        //public Shader blurEffectShader;
        //Boolean for if the blur effect was originally enabled
        //public Boolean blurBool;

        /// <summary>
        /// The start method; you will need to place all of your inital value getting/setting here.
        /// </summary>
        public void Start()
        {
            ReadUseSimpleTerrain = UseSimpleTerrain;
            if (UseSimpleTerrain)
            {
                ReadSimpleTerrain = SimpleTerrain;
            }
            else
            {
                ReadTerrain = Terrain;
            }

            MainCamShared = MainCam;
            //Set the lastmusicmult and last audiomult
            LastMusicMult = AudioMusicSlider.value;
            LastAudioMult = AudioEffectsSlider.value;
            //Set the first selected item
            UiEventSystem.firstSelectedGameObject = DefualtSelectedMain;
            //Get the presets from the quality settings
            _presets         = QualitySettings.names;
            PresetLabel.text = _presets[QualitySettings.GetQualityLevel()].ToString();
            _currentLevel    = QualitySettings.GetQualityLevel();
            //Get the current resoultion, if the game is in fullscreen, and set the label to the original resolution
            _allRes           = Screen.resolutions;
            CurrentRes.width  = Screen.width;
            CurrentRes.height = Screen.height;
            //Debug.Log("ini res" + currentRes);
            ResolutionLabel.text = Screen.width.ToString() + " x " + Screen.height.ToString();
            _isFullscreen        = Screen.fullScreen;
            //get initial screen effect bools
            _lastAoBool  = AoToggle.isOn;
            _lastDofBool = DofToggle.isOn;
            //get all specified audio source volumes
            _beforeEffectVol = new float[_audioEffectAmt];
            BeforeMaster     = AudioListener.volume;
            //get all ini values
            AaQualIni     = QualitySettings.antiAliasing;
            RenderDistIni = MainCam.farClipPlane;
            ShadowDistIni = QualitySettings.shadowDistance;
            FovIni        = MainCam.fieldOfView;
            MsaaIni       = QualitySettings.antiAliasing;
            VsyncIni      = QualitySettings.vSyncCount;
            //enable titles
            TitleTexts.SetActive(true);
            //Find terrain
            Terrain = Terrain.activeTerrain;
            //Disable other panels
            MainPanel.SetActive(false);
            VidPanel.SetActive(false);
            AudioPanel.SetActive(false);
            CreditsPanel.SetActive(false);
            //Enable mask
            Mask.SetActive(false);
            //set last texture limit
            LastTexLimit = QualitySettings.masterTextureLimit;
            //set last shadow cascade
            LastShadowCascade = QualitySettings.shadowCascades;
            try
            {
                _saveSettings.LoadGameSettings();
            }
            catch
            {
                Debug.Log("Game settings not found in: " + Application.persistentDataPath + "/" + _saveSettings.FileName);
                _saveSettings.SaveGameSettings();
            }

            try
            {
                DensityIni = Terrain.activeTerrain.detailObjectDensity;
            }
            catch
            {
                if (Terrain = null)
                {
                    Debug.Log("Terrain Not Assigned");
                }
            }

            //set the blur boolean to false;
            //blurBool = false;
            //Add the blur effect

            /*mainCamObj.AddComponent(typeof(Blur));
             * blurEffect = (Blur)mainCamObj.GetComponent(typeof(Blur));
             * blurEffect.blurShader = blurEffectShader;
             * blurEffect.enabled = false;  */
        }