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); } } }