private byte[] CreateAssetbundleBytes(out AssetBundle ab) { ab = AssetBundle.LoadFromFile(BundlePathConvert.GetRunningPath(BundleConfig.depAssetBundlePath)); if (ab != null) { BundlePkgAsset asset = ab.LoadAsset <BundlePkgAsset>(ab.GetAllAssetNames()[0]); return(asset.bytes); } return(null); }
protected AssetBundleCreateRequest LoadFullAssetToMemAsync(BundlePkgInfo pkginfo) { if (Application.isPlaying && MainLoop.getInstance()) { return(KAssetBundle.LoadFromFileAsync(BundlePathConvert.GetRunningPath(pkginfo.AbFileName)));; } else { return(null); } }
protected IBundleRef LoadFullAssetToMem(BundlePkgInfo pkginfo) { IBundleRef bundle = null; if (ResBundleMgr.mIns.Cache.Contains(pkginfo)) { bundle = ResBundleMgr.mIns.Cache.TryGetValue(pkginfo); return(bundle); } #if UNITY_IOS || UNITY_IPHONE || UNITY_ANDROID if (GameApplication.isPlaying && MainLoop.getInstance().OpenABMode) { AssetBundle ab = null; using (gstring.Block()) { ab = this.LoadAssetBundle(BundlePathConvert.GetRunningPath(pkginfo.AbFileName)); } if (ab == null) { this.ThrowAssetMissing(this.LoadResPath); } bundle = ResBundleMgr.mIns.Cache.PushAsset(pkginfo, ab); return(bundle); } else #endif { UnityEngine.Object target = AssetDatabaseLoad(pkginfo.EditorPath); if (target == null) { if (BundleConfig.SAFE_MODE) { this.ThrowAssetMissing(pkginfo.BundleName); } else { this.LoadState = BundleLoadState.Error; LogMgr.LogErrorFormat("Asset {0} Missing", pkginfo.BundleName); } } else { #if UNITY_EDITOR bundle = ResBundleMgr.mIns.Cache.PushEditorAsset(pkginfo, target); #endif } return(bundle); } }
private void Start() { targetVerPath = BundlePathConvert.GetRunningPath(BundleConfig.ABVersionPath); AssetBundle ab = null; byte[] assetbytes = CreateAssetbundleBytes(out ab); if (assetbytes != null && assetbytes.Length > 4) { LoadAssetbundleBytes(assetbytes); ab.Unload(true); } else { LogMgr.LogError("Res Init Error"); } }
public static BundleRef Create(KAssetBundle ab, string abname, string loadname, string bundlename) { BundleRef bundle = new BundleRef(); bundle.Res = ab; bundle.depends = new List <IBundleRef>(); bundle.refs = new List <WeakReference>(); if (ab.isStreamedSceneAssetBundle) { bundle.LoadName = System.IO.Path.GetFileNameWithoutExtension(ab.GetAllScenePaths()[0]); } else { bundle.LoadName = BundlePathConvert.EditorName2AssetName(loadname); } bundle.name = bundlename; bundle.filename = abname; return(bundle); }
private void Start() { string depFileName = null; using (gstring.Block()) { depFileName = BundlePathConvert.GetRunningPath(BundleConfig.ABVersionPath); targetVerPath = string.Copy(depFileName); AssetBundle ab = null; byte[] assetbytes = CreateAssetbundleBytes(out ab); if (assetbytes != null && assetbytes.Length > 4) { LoadAssetbundleBytes(assetbytes); ab.Unload(true); } else { LogMgr.LogError("Res Init Error"); } } }