Пример #1
0
        /// <summary>
        /// Saves the video settings for this game
        /// </summary>
        /// <param name="data">The data to be saved</param>
        public static void SaveVideo(VideoData data)
		{
#if UNITY_WEBPLAYER
            // Set appropriate hash values
			PlayerPrefs.SetInt(videoHash + 0, data.ResolutionIndex);
			PlayerPrefs.SetInt(videoHash + 1, data.QualityIndex);
			int full = data.Fullscreen ? 1 : 0;
			PlayerPrefs.SetInt(videoHash + 2, full);
#else
            // Create a new save file
            BinaryFormatter bf = new BinaryFormatter();
			FileStream file = File.Create(videoDataPath);
			
			bf.Serialize(file, data);
			file.Close();
#endif
		}
Пример #2
0
        public static void SaveVideo(int _resolutionIndex, int _qualityIndex, bool _fullscreen)
        {
            #if UNITY_WEBPLAYER
            PlayerPrefs.SetInt(_videoHash + 0, _resolutionIndex);
            PlayerPrefs.SetInt(_videoHash + 1, _qualityIndex);
            int _full = _fullscreen ? 1 : 0;
            PlayerPrefs.SetInt(_videoHash + 2, _full);
            #else
            BinaryFormatter _bf = new BinaryFormatter();
            FileStream _file = File.Create(_videoDataPath);

            VideoData _data = new VideoData(_resolutionIndex, _qualityIndex, _fullscreen);

            _bf.Serialize(_file, _data);
            _file.Close();
            #endif
        }
Пример #3
0
        /// <summary>
        /// Loads the video data for this game
        /// </summary>
        /// <returns>The video settings saved to disk or player prefs</returns>
		public static VideoData LoadVideo()
		{
            // Get a default videodata in case none exists
            VideoData data = new VideoData();
#if UNITY_WEBPLAYER
            // If there is data related to video, get those values
			if(PlayerPrefs.HasKey(videoHash + 0))
			{
				data.ResolutionIndex = PlayerPrefs.GetInt(videoHash + 0);
				data.QualityIndex = PlayerPrefs.GetInt(videoHash + 1);
				int full = PlayerPrefs.GetInt(videoHash + 2);
				data.Fullscreen = (full == 1) ? true : false;
			}
            // Otherwise save the default data
			else
			{
				SaveManager.SaveVideo(new VideoData());
			}
			return data;
#else
            // If a file exists
            if (File.Exists(videoDataPath))
			{
				BinaryFormatter bf = new BinaryFormatter();
				FileStream file = File.Open(videoDataPath, FileMode.Open);
				
				data = (VideoData)bf.Deserialize(file);
				
				file.Close();
				
				return data;
			}
            // No file exists, so save the default data
            else
            {
				SaveManager.SaveVideo(data);
				return data;
			}
#endif
		}
Пример #4
0
        public static VideoData LoadVideo()
        {
            VideoData _data = new VideoData();
            #if UNITY_WEBPLAYER

            if(PlayerPrefs.HasKey(_videoHash + 0))
            {
                _data.ResolutionIndex = PlayerPrefs.GetInt(_videoHash + 0);
                _data.QualityIndex = PlayerPrefs.GetInt(_videoHash + 1);
                int _full = PlayerPrefs.GetInt(_videoHash + 2);
                _data.Fullscreen = (_full == 1) ? true : false;
            }
            else
            {
                SaveManager.SaveVideo(_data.ResolutionIndex, _data.QualityIndex, _data.Fullscreen);
            }
            return _data;
            #else

            if(File.Exists(_videoDataPath))
            {
                BinaryFormatter _bf = new BinaryFormatter();
                FileStream _file = File.Open(_videoDataPath, FileMode.Open);

                _data = (VideoData)_bf.Deserialize(_file);

                _file.Close();

                return _data;
            }
            else
            {
                VideoData _newData = new VideoData();
                SaveManager.SaveVideo(_data.ResolutionIndex, _data.QualityIndex, _data.Fullscreen);
                return _newData;
            }
            #endif
        }