private static GrtPackge _create(Stream _stream) { lock ( s_buffer ) { GrtPackge package = new GrtPackge(); _stream.Seek(-8, SeekOrigin.End); _stream.Read(s_buffer, 0, 8); Int64 start_idx = BitConverter.ToInt64(s_buffer, 0); _stream.Seek(start_idx, SeekOrigin.Begin); // 读取描述段 while (_stream.Position < _stream.Length - 8) { GrtFile grt_file = new GrtFile(); _stream.Read(s_buffer, 0, 8); grt_file.Size = BitConverter.ToInt64(s_buffer, 0); _stream.Read(s_buffer, 0, 8); grt_file.CompressedSize = BitConverter.ToInt64(s_buffer, 0); _stream.Read(s_buffer, 0, 8); grt_file.Offset = BitConverter.ToInt64(s_buffer, 0); Byte file_name_length = (Byte)_stream.ReadByte(); _stream.Read(s_buffer, 0, file_name_length); grt_file.Name = System.Text.Encoding.UTF8.GetString(s_buffer, 0, file_name_length); package.m_files.Add(grt_file.Name, grt_file); Debug.LogFormat("name: {0}, size: {1} compressed_size: {2}, offset: {3}", grt_file.Name, grt_file.Size, grt_file.CompressedSize, grt_file.Offset); } return(package); } }
private IEnumerator _loadFileBinaryFile(Resource_GrtPackage _assetbundle_data) { using (WWW www = new WWW(_assetbundle_data.ResouceInfo.UnityApiLoadingPath)) { yield return(www); if (www.error != null) { Utility.Log.Error(Utility.eLogType.Resources, "Binary file [{0}] load fail:! Msg: {1}", _assetbundle_data.ResouceInfo.UnityApiLoadingPath, www.error); } _assetbundle_data.OnLoadFinish(www.error != null ? null : GrtPackge.CreateFromeMemory(www.bytes)); } m_current_loading = null; }
public void OnLoadFinish(GrtPackge _package) { Package = _package; State = _package == null ? ResourceState.Error : ResourceState.Loaded; }
public override void Unload(bool _unload_all = false) { Package = null; State = ResourceState.NotLoaded; }