// AudioClip WriteCacheFileSound { get; } // byte[] CacheWriteBytes { get; } /// <summary> /// コンストラクタ /// </summary> /// <param name="info">ファイル情報</param> /// <param name="fileIO">ファイルのIO管理クラス</param> public AssetFileWork(AssetFileInfo info, FileIOManagerBase fileIO) { this.FileName = info.Key; this.FileInfo = info; this.fileIO = fileIO; this.status = STAUS.LOAD_WAIT; this.Priority = AssetFileLoadPriority.DownloadOnly; this.SubFiles = new Dictionary <string, AssetFile>(); }
//ロード処理(暗号化済みファイルから) void LoadWWWCriptFile(WWW www) { byte[] readBytes = www.bytes; switch (FileType) { case AssetFileType.Text: //テキスト text = System.Text.Encoding.UTF8.GetString(fileIO.Decode(readBytes)); break; case AssetFileType.Bytes: //バイナリ bytes = fileIO.Decode(readBytes); break; case AssetFileType.Texture: //テクスチャ fileIO.DecodeNoCompress(readBytes); //圧縮なしでデコード //サイズとTextureFormatはLoadImage後無視される。ミップマップの反映のみ texture = new Texture2D(1, 1, TextureFormat.ARGB32, FileInfo.IsTextureMipmap); if (texture.LoadImage(readBytes)) { texture.name = FileInfo.FilePath; texture.wrapMode = TextureWrapMode.Clamp; //ReadWriteフラグの設定 if (RowData != null && RowData.ParseCellOptional("ReadWrite", false)) { texture.Apply(false, false); } else { texture.Apply(false, true); } } else { Debug.LogError(" Filed load image " + FileInfo.FilePath); } break; case AssetFileType.Sound: //サウンド fileIO.DecodeNoCompress(readBytes); //圧縮なしでデコード sound = FileIOManagerBase.ReadAudioFromMem(this.FileName, readBytes); sound.name = FileInfo.FilePath; break; case AssetFileType.Csv: //CSV csv = new StringGrid(this.FileName, FileInfo.IsTsv ? CsvType.Tsv : CsvType.Csv, System.Text.Encoding.UTF8.GetString(fileIO.Decode(readBytes))); break; case AssetFileType.UnityObject: Debug.LogError("AssetBundle not support load from utage cript cache file"); break; default: break; } }
/// <summary> /// コンストラクタ /// </summary> /// <param name="info">ファイル情報</param> /// <param name="fileIO">ファイルのIO管理クラス</param> internal AssetFileUtage(AssetFileUtageManager manager, AssetFileInfo info, StringGridRow rowData, FileIOManagerBase fileIO) { this.manager = manager; this.fileIO = fileIO; this.FileName = info.Key; this.FileInfo = info; this.status = STAUS.LOAD_WAIT; this.Priority = AssetFileLoadPriority.DownloadOnly; this.SubFiles = new Dictionary <string, AssetFile>(); this.RowData = rowData; }
public override bool WriteEncode(string path, byte[] bytes) { try { this.FileWriteAllBytes(path, FileIOManagerBase.CustomEncode(this.CryptKeyBytes, bytes)); return(true); } catch (Exception exception) { object[] args = new object[] { path, exception.ToString() }; Debug.LogError(LanguageErrorMsg.LocalizeTextFormat(ErrorMsg.FileWrite, args)); return(false); } }
//ロード処理(暗号化済みキャッシュファイルから) void LoadWWWCriptCacheFile(WWW www) { #if !(UNITY_WEBPLAYER || UNITY_WEBGL) byte[] readBytes = www.bytes; switch (FileType) { case AssetFileType.Text: //テキスト text = System.Text.Encoding.UTF8.GetString(fileIO.Decode(readBytes)); break; case AssetFileType.Bytes: //バイナリ bytes = fileIO.Decode(readBytes); break; case AssetFileType.Texture: //テクスチャ fileIO.DecodeNoCompress(readBytes); //圧縮なしでデコード //サイズとTextureFormatはLoadImage後無視される。ミップマップの反映のみ texture = new Texture2D(1, 1, TextureFormat.ARGB32, FileInfo.IsTextureMipmap); texture.LoadImage(readBytes); texture.name = FileInfo.FilePath; texture.wrapMode = TextureWrapMode.Clamp; texture.Apply(false, false); break; case AssetFileType.Sound: //サウンド fileIO.DecodeNoCompress(readBytes); //圧縮なしでデコード sound = FileIOManagerBase.ReadAudioFromMem(this.Key, readBytes); sound.name = FileInfo.FilePath; break; case AssetFileType.Csv: //CSV csv = new StringGrid(this.LoadingPath, FileInfo.IsTsv ? CsvType.Tsv : CsvType.Csv, System.Text.Encoding.UTF8.GetString(fileIO.Decode(readBytes))); break; case AssetFileType.UnityObject: Debug.LogError("AssetBundle not support load from utage cript cache file"); break; default: break; } #endif }
public override bool WriteBinaryEncode(string path, Action <BinaryWriter> callbackWrite) { try { using (MemoryStream stream = new MemoryStream()) { using (BinaryWriter writer = new BinaryWriter(stream)) { callbackWrite(writer); } this.FileWriteAllBytes(path, FileIOManagerBase.CustomEncode(this.CryptKeyBytes, stream.ToArray())); } return(true); } catch (Exception exception) { object[] args = new object[] { path, exception.ToString() }; Debug.LogError(LanguageErrorMsg.LocalizeTextFormat(ErrorMsg.FileWrite, args)); return(false); } }
public override bool WriteSound(string path, AudioClip audioClip) { try { FileIOManagerBase.audioHeader[0] = audioClip.get_samples(); FileIOManagerBase.audioHeader[2] = audioClip.get_frequency(); FileIOManagerBase.audioHeader[1] = audioClip.get_channels(); int num = audioClip.get_samples() * audioClip.get_channels(); using (FileStream stream = new FileStream(path, FileMode.Create, FileAccess.Write)) { Buffer.BlockCopy(FileIOManagerBase.audioHeader, 0, FileIOManagerBase.workBufferArray, 0, 12); FileIOManagerBase.CustomEncodeNoCompress(this.CryptKeyBytes, FileIOManagerBase.workBufferArray, 0, 12); stream.Write(FileIOManagerBase.workBufferArray, 0, 12); int num2 = 0; do { int num3 = Math.Min(FileIOManagerBase.audioSamplesWorkArray.Length, num - num2); audioClip.GetData(FileIOManagerBase.audioSamplesWorkArray, num2 / audioClip.get_channels()); for (int i = 0; i < num3; i++) { FileIOManagerBase.audioShortWorkArray[i] = (short)(32767f * FileIOManagerBase.audioSamplesWorkArray[i]); } int count = num3 * 2; Buffer.BlockCopy(FileIOManagerBase.audioShortWorkArray, 0, FileIOManagerBase.workBufferArray, 0, count); FileIOManagerBase.CustomEncodeNoCompress(this.CryptKeyBytes, FileIOManagerBase.workBufferArray, 0, count); stream.Write(FileIOManagerBase.workBufferArray, 0, count); num2 += num3; }while (num2 < num); } return(true); } catch (Exception exception) { Debug.LogError(exception.ToString()); return(false); } }
public override bool ReadBinaryDecode(string path, Action <BinaryReader> callbackRead) { try { if (!this.Exists(path)) { return(false); } using (MemoryStream stream = new MemoryStream(FileIOManagerBase.CustomDecode(this.CryptKeyBytes, this.FileReadAllBytes(path)))) { using (BinaryReader reader = new BinaryReader(stream)) { callbackRead(reader); } } return(true); } catch (Exception exception) { object[] args = new object[] { path, exception.ToString() }; Debug.LogError(LanguageErrorMsg.LocalizeTextFormat(ErrorMsg.FileRead, args)); return(false); } }
public override bool WriteEncodeNoCompress(string path, byte[] bytes) { try { using (FileStream stream = new FileStream(path, FileMode.Create, FileAccess.Write)) { int srcOffset = 0; do { int count = Math.Min(0x40000, bytes.Length - srcOffset); Buffer.BlockCopy(bytes, srcOffset, FileIOManagerBase.workBufferArray, 0, count); FileIOManagerBase.CustomEncodeNoCompress(this.CryptKeyBytes, FileIOManagerBase.workBufferArray, 0, count); stream.Write(FileIOManagerBase.workBufferArray, 0, count); srcOffset += count; }while (srcOffset < bytes.Length); } return(true); } catch (Exception exception) { Debug.LogError(exception.ToString()); return(false); } }
public override byte[] EncodeNoCompress(byte[] bytes) { FileIOManagerBase.CustomEncodeNoCompress(this.CryptKeyBytes, bytes, 0, bytes.Length); return(bytes); }
public override byte[] Encode(byte[] bytes) { return(FileIOManagerBase.CustomEncode(this.CryptKeyBytes, bytes)); }
public override void DecodeNoCompress(byte[] bytes) { FileIOManagerBase.CustomDecodeNoCompress(this.CryptKeyBytes, bytes, 0, bytes.Length); }