public override void Update() { if (State == LoaderState.Loading) { if (m_abRequest != null) { if (m_abRequest.isDone) { ++m_stageCurrent; OnLoaded(m_abRequest.assetBundle); } else { DoProgress(m_abRequest.progress); } } else if (m_unpackRequest != null) { if (m_unpackRequest.IsDone) { ++m_stageCurrent; m_abRequest = AssetBundle.LoadFromMemoryAsync(m_unpackRequest.Bytes); m_unpackRequest.Dispose(); m_unpackRequest = null; } else { DoProgress(m_unpackRequest.Progress); } } } }
public override void Update() { if (state == LoaderState.Loading) { if (m_AssetBundleCreateRequest != null) { if (m_AssetBundleCreateRequest.isDone) { ++m_StageCurrent; OnComplete(m_AssetBundleCreateRequest.assetBundle); } else { OnProgress(m_AssetBundleCreateRequest.progress); } } else if (m_LzmaCompressRequest != null) { if (m_LzmaCompressRequest.isDone) { ++m_StageCurrent; m_AssetBundleCreateRequest = AssetBundle.LoadFromMemoryAsync(m_LzmaCompressRequest.bytes); m_LzmaCompressRequest.Dispose(); m_LzmaCompressRequest = null; } else { OnProgress(m_LzmaCompressRequest.progress); } } } }
public static LzmaCompressRequest CreateDecompress(byte[] bytes) { LzmaCompressRequest request = new LzmaCompressRequest(); request.Decompress(bytes); return(request); }
public static LzmaCompressRequest CreateCompress(byte[] data) { LzmaCompressRequest request = new LzmaCompressRequest(); request.Compress(data); return(request); }
public override void Reset() { base.Reset(); m_AssetBundleCreateRequest = null; m_LzmaCompressRequest = null; m_StageCurrent = 0; m_StageCount = 1; }
public override void Reset() { base.Reset(); m_abRequest = null; m_unpackRequest = null; m_stageCurrent = 0; m_stageCount = 1; }
public override void Start() { base.Start(); string path = ResourceManager.instance.GetResourcePath(this.path); if (string.IsNullOrEmpty(path)) { OnFailed(); return; } m_NeedDecompress = ConstantData.enableCustomCompress && path.Contains(ConstantData.streamingAssetsPath); if (async) { if (m_NeedDecompress) { m_StageCount = 2; byte[] bytes = FileUtil.ReadByteFromFile(path); m_LzmaCompressRequest = LzmaCompressRequest.CreateDecompress(bytes); } else { m_AssetBundleCreateRequest = AssetBundle.LoadFromFileAsync(path); } } else { AssetBundle assetbundle = null; try { if (m_NeedDecompress) { byte[] bytes = FileUtil.ReadByteFromFile(path); bytes = Decompress(bytes); assetbundle = AssetBundle.LoadFromMemory(bytes); } else { assetbundle = AssetBundle.LoadFromFile(path); } } catch (Exception e) { UnityEngine.Debug.LogError(e.Message); } finally { OnComplete(assetbundle); } } }
public override void Load() { base.Load(); string path = LoadMgr.Inst.GetResourcePath(Path); if (string.IsNullOrEmpty(path)) { OnLoaded(null); return; } m_needUnpack = ConstantData.EnableCustomCompress && path.Contains(ConstantData.StreamingAssetsPath); if (IsAsync) { if (m_needUnpack) { m_stageCount = 2; byte[] bytes = FileHelper.ReadByteFromFile(path); m_unpackRequest = LzmaCompressRequest.CreateDecompress(bytes); } else { m_abRequest = AssetBundle.LoadFromFileAsync(path); } } else { AssetBundle ab = null; try { if (m_needUnpack) { byte[] bytes = FileHelper.ReadByteFromFile(path); bytes = Unpack(bytes); ab = AssetBundle.LoadFromMemory(bytes); } else { ab = AssetBundle.LoadFromFile(path); } } catch (Exception e) { Logger.LogError(e.Message); } finally { OnLoaded(ab); } } }