public void AddParent(BundleLoader parent) { if (null != parent) { m_parents.Add(parent); } }
public AssetBundle LoadAssetBundle(string bundleName, bool cache = true) { if (assetBundleCache.ContainsKey(bundleName)) { return(assetBundleCache[bundleName]); } AssetBundle bundle = null; var memory = BundleLoader.LoadFileMemory(LocalVersionConfig.bundleRelativePath + "/" + bundleName + BundleConfig.suffix); using (var bundleStream = BundleEncode.DeompressAndDecryptLZMA(memory, password)) { if (bundleStream == null) { return(bundle); } bundle = AssetBundle.CreateFromMemoryImmediate(bundleStream.ToArray()); if (bundle == null) // 如果没有则直接返回 { return(bundle); } } if (cache) { assetBundleCache.Add(bundleName, bundle); } return(bundle); }
public bool Load(string bundleName, bool loadAssets) { try { mBundleName = bundleName; mAssetBundle = BundleLoader.LoadBundleFromSDCard(mBundleName); if (mAssetBundle == null) { //Logger.ErrorLog("SharedLoaderObject.Load Error!!! LoadFromFile Fild: Path:{0}", bundlePath); return(false); } int startIdx = mBundleName.LastIndexOf("/"); int endIdx = mBundleName.LastIndexOf("."); assName = mBundleName.Substring(startIdx + 1, endIdx - startIdx - 1); if (loadAssets) { mMainObject = mAssetBundle.LoadAsset(assName); } return(true); } catch { return(false); } }
private void ToNode(int n) { if (n == 0 && currentNode.id != 0) { Finish(); return; } if (currentSpeechPanel) { currentSpeechPanel.gameObject.SetActive(false); } currentNode = story.Nodes[n]; var charName = currentNode.character; if (charName == "...") { currentSpeechPanel = tutorialSpeechPanel; } else { currentSpeechPanel = charName == "player" ? playerSpeechPanel : neutralSpeechPanel; if (!characterDict.ContainsKey(charName)) { characterDict.Add(charName, BundleLoader.LoadCharacter(charName)); } } currentSpeechPanel.SetNode(currentNode); currentSpeechPanel.gameObject.SetActive(true); }
void Start() { BundleLoader bundleLoader = new BundleLoader(); bundleLoader.Init(); CheckAssetsInScreamBundle(bundleLoader); CheckValidJsonData(bundleLoader); }
private void Start() { bundleLoader = new BundleLoader(loadBundleFrom); string zeusBeardUrl = "https://www.stubuchbinder.com/groomify/ios/zeus_beard.unity3d"; LoadUrl(zeusBeardUrl); }
public BundleLoader GetBundleLoader(string abName) { BundleLoader cache = null; m_BundleLoaders.TryGetValue(abName, out cache); return(cache); }
public void TryRelease(BundleLoader assetLoader, bool unloadFlag) { if (0 >= --mReferance) { assetLoader.RemoveAssetBundle(mBundleName); mAssetBundle.Unload(unloadFlag); CleanUp(); } }
private Dictionary <string, BundleLoader> m_BundleLoaders = new Dictionary <string, BundleLoader>(); //记录所有加载中的包 public void AddBundleLoader(string abName, BundleLoader loader) { if (m_BundleLoaders.ContainsKey(abName)) { Util.LogError("包已经在加载中了,你又重复加载了,包名:" + abName); } m_BundleLoaders.Add(abName, loader); }
// Use this for initialization void Start() { Dictionary <string, HashSet <string> > map = new Dictionary <string, HashSet <string> >(); BundleLoader bundleLoader = new BundleLoader(); bundleLoader.Init(); getStatistic(map, bundleLoader); extraxt(map, bundleLoader); }
void Start() { this.bundleLoader = new BundleLoader(); this.bundleLoader.Init(); this.sceneLoader = new SceneLoader(this.bundleLoader); this.sceneLoader.LoadScene("Garage"); this.InitHullDb(); this.StartCoroutine(this.AwaitLoadMap()); }
public void SetUp() { _cachedLoader = Substitute.For <IBundleCachedLoader>(); // Mock bundleManifest _bundleManifestLoader = Substitute.For <IBundleManifestLoader>(); _bundleManifest = Substitute.For <IBundleManifest>(); _bundleManifestLoader.Load().Returns(Observable.Return(_bundleManifest)); _fixture = new BundleLoader(_cachedLoader, _bundleManifestLoader); }
private void OnBundleLoaded(BundleLoader obj) { var prefabs = new List <PlainObject>(); foreach (var bundlePref in obj.Prefabs) { prefabs.Add(bundlePref.GetComponent <PlainObject>()); } _prefabs = prefabs.ToArray(); }
private void Start() { this.bundleLoader = new BundleLoader(); this.bundleLoader.Init(); this.sceneLoader = new SceneLoader(this.bundleLoader); this.scenePatchs = this.sceneLoader.GetScenePatchs(); this.scenePatchs.ForEach(scenePatch => this.Dropdown.AddOptions( new List <Dropdown.OptionData> { new Dropdown.OptionData(System.IO.Path.GetFileNameWithoutExtension(scenePatch)) } )); }
protected override void Awake() { base.Awake(); if (Instance == this) { DontDestroyOnLoad(gameObject); bundleQueue = new Queue <BundleQueueItem>(); bundleLoader = gameObject.GetOrAddComponent <BundleLoader>(); #if UNITY_EDITOR //bundleLoader.isUsingLocalBundle = true; #endif } }
// 加载资源清单 void LoadManifest(ManifestType mType) { if (m_manifests.ContainsKey(mType) && m_manifests[mType] != null) { DestroyImmediate(m_manifests[mType], true); m_manifests.Remove(mType); } string manifestName = mType.ToString(); Util.Log("LoadManifest manifestName " + manifestName); m_manifestNames.Add(manifestName); string strFullPath = FileHelper.SearchFilePath(GetManifestType(manifestName).ToString(), manifestName); Util.Log("strFullPath: " + strFullPath); BundleLoader bLoader = LoaderPool.Instance.GetLoader <BundleLoader>(); bLoader.Init(strFullPath, manifestName, delegate(object data) { LoadedBundle ab = data as LoadedBundle; if (ab != null) { m_manifests[mType] = ab.LoadAsset <AssetBundleManifest>("AssetBundleManifest"); m_bundleHeads[mType] = mType.ToString().ToLower().Split('_')[0]; Util.Log("manifest ab in not null over----"); } else { Util.LogError("manifest ab is null---------"); } LoadedBundleCtrl.Instance.UnReferenceLoadedBundle(manifestName); // 不走统一接口是因为manifest文件没有后缀 LoadedBundleCtrl.Instance.HandRemoveBundle(manifestName); if (m_manifests[mType] != null) { string[] bundles = m_manifests[mType].GetAllAssetBundles(); for (int i = 0; i < bundles.Length; ++i) { if (m_bundleNames.Contains(bundles[i])) { Util.LogError(string.Format("别的清单已同名的包名,{0} {1}", manifestName, bundles[i])); } m_bundleNames.Add(bundles[i]); } } }, false, null, true); }
void Awake() { stories = new List <Story>(); var allStoriesTexts = BundleLoader.LoadAllStories(); foreach (var storyText in allStoriesTexts) { Node[] nodes = JsonHelper.FromJson <Node>(storyText.ToString()); Story story = new Story(); story.Nodes = nodes; stories.Add(story); } }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Unity content (*.unity3d;*.assets)|*.unity3d;*.assets|Bundle file (*.unity3d)|*.unity3d|Assets file (*.assets)|*.assets|All types (*.*)|*.*"; if (ofd.ShowDialog() == DialogResult.OK) { //try //{ //todo, use using FileStream stream = new FileStream(ofd.FileName, FileMode.Open, FileAccess.ReadWrite); AssetsFileReader tempReader = new AssetsFileReader(stream); //todo .assets sanity check if (tempReader.ReadStringLength(7) != "UnityFS") { tempReader.Position = 0; AssetViewer av = new AssetViewer(stream, Path.GetDirectoryName(stream.Name), Path.GetFileName(stream.Name)); av.ShowDialog(); } else { tempReader.Position = 0; BundleLoader bl = new BundleLoader(stream); bl.ShowDialog(); if (bl.loaded) { bundleContents.Enabled = true; exportButton.Enabled = true; importButton.Enabled = true; infoButton.Enabled = true; foreach (AssetsBundleDirectoryInfo06 di in bl.bundle.bundleInf6.dirInf) { bundleContents.Items.Add(di.name); } bundleContents.SelectedIndex = 0; bundlePath = bl.bundleFilename; fileName.Text = Path.GetFileName(bundlePath); bundle = bl.bundle; } } tempReader = null; //} catch (Exception ex) //{ // MessageBox.Show("Unable to open the file!\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); //} } }
private static void extraxt(Dictionary <string, HashSet <string> > map, BundleLoader bundleLoader) { bundleLoader.GetLoadedAssetBundles() .Where(bundle => bundle != null && !bundle.isStreamedSceneAssetBundle) .Take(40) .ToList() .ForEach(bundle => { bundle.GetAllAssetNames() .ToList() .ForEach(assetName => { Object asset = bundle.LoadAsset(assetName); if (assetName.Split('.').Last().Equals("png") && asset as UnityEngine.Texture2D) { } }); }); }
public SceneLoader(BundleLoader bundleLoader) { this.bundleLoader = bundleLoader; this.bundleLoader.loadedBundles.Values .Where(assetBundle => assetBundle != null) .Where(assetBundle => assetBundle.isStreamedSceneAssetBundle) .ToList() .ForEach(assetBundle => { assetBundle.GetAllScenePaths() .ToList() .ForEach(scenePath => { this.scenes.Add(scenePath, assetBundle.name); Debug.Log(scenePath + "------" + assetBundle.name); }); }); }
public BundleLoader.BundleState LoadAssetBundle(string path, LoadedCallback onLoaded, bool async = true, BundleLoader parent = null) { string abName = FileHelper.CheckBundleName(path); if (!ManifestHasBundleInfo(abName)) { if (onLoaded != null) { onLoaded(null); } return(BundleLoader.BundleState.NotExist); } LoadedBundle loadedCache = LoadedBundleCtrl.Instance.ReferenceLoadedBundle(abName); if (loadedCache != null) { if (onLoaded != null) { onLoaded(loadedCache); } return(BundleLoader.BundleState.Loaded); } BundleLoader loadingCache = BundleLoaderCtrl.Instance.GetBundleLoader(abName); if (loadingCache != null) { loadingCache.AddHandleCallBack(onLoaded); loadingCache.AddParent(parent); return(BundleLoader.BundleState.Loading); } string fullpath = FileHelper.SearchFilePath(GetManifestType(abName).ToString(), abName); //包最终加载路径 BundleLoader bLoader = LoaderPool.Instance.GetLoader <BundleLoader>(); bLoader.Init(fullpath, abName, onLoaded, async, parent); return(BundleLoader.BundleState.JustLoad); }
public AssetBundleManager(AssetBundleManagerConfig cfg, GameObject owner) { config = cfg; freeStreams = config.numBundleLoaders; streams = new List <Coroutine>(); loadHandlers = new Dictionary <string, Action <string> >(); cache = new AssetBundleCache(); loader = owner.AddComponent <BundleLoader>(); updater = owner.AddComponent <BundleManagerUpdate>(); updater.Init(this); loadOps = new ObjectPool <BundleLoadOperation>(16, true) { OnInstantiate = () => new BundleLoadOperation(this) }; loadOps.Fill(); // check cfg.bundleTarget and start local server if necessary. }
internal static bool Exist(string aniFile) { //先判断自动更新目录 string noUse; if (BundleLoader.BundleExistInUpdatePath(aniFile, out noUse)) { return(true); } #if UNITY_ANDROID && !UNITY_EDITOR var bundlePath = BundleNameSplit(aniFile); string realpath, nouse; var needUpdate = BundleLoader.Instance.GetBundleRealPath(AddBundleExt(bundlePath[0]), out realpath, out nouse); if (needUpdate) { return(true); } var filepath = realpath.Substring(realpath.IndexOf("assets/")); var item = BundleLoader.Instance.ZipFile.GetEntry(filepath); return(item != null); #else if (sInstance.UseAssetBundle) { aniFile = aniFile.Replace("\\", "/"); var fileName = aniFile.Replace("/", "_"); #if UNITY_EDITOR var path = Path.Combine( Path.Combine(Path.Combine(Application.dataPath, "BundleAsset"), Path.GetDirectoryName(aniFile)), Path.GetFileNameWithoutExtension(fileName)) + ".unity3d"; #else var path = Path.Combine( Path.Combine(Application.streamingAssetsPath, Path.GetDirectoryName(aniFile)), Path.GetFileNameWithoutExtension(fileName)) + ".unity3d"; #endif return(File.Exists(path)); } return(File.Exists(Path.Combine(Path.Combine(Application.dataPath, "Res"), aniFile))); #endif }
private static void CheckValidJsonData(BundleLoader bundleLoader) { int count = bundleLoader.GetLoadedAssetBundles() .Where(assetBundle => assetBundle != null) .Where(assetBundle => { List <BundleInfo> bunleList = bundleLoader.db.bundles .Where(bundleInfo => bundleInfo.bundleName == assetBundle.name) .ToList(); if (assetBundle.isStreamedSceneAssetBundle) { Debug.Log(bunleList[0].assets.Length == assetBundle.GetAllScenePaths().Length); } else { Debug.Log(bunleList[0].assets.Length == assetBundle.GetAllAssetNames().Length); } return(true); }).ToList().Count; Debug.Log(count); }
// \IGameService /// <summary> /// Получить загрузчик бандла. /// </summary> /// <param name="bundleName">Имя бандла, для которого получается загрузчик.</param> /// <returns>Загрузчик бандла.</returns> public BundleLoader GetBundleLoader(string bundleName) { if (!Ready.Value) { Debug.LogError("BundleManager is not initialized yet."); return(null); } if (BundleLoadersMap.TryGetValue(bundleName, out var loader)) { return(loader); } if (!_bundleDataMap.TryGetValue(bundleName, out var data)) { Debug.LogErrorFormat("There is no data for bundle {0} in manifest.", bundleName); return(null); } loader = new BundleLoader(data, _audioManager); BundleLoadersMap.Add(bundleName, loader); return(loader); }
private static void CheckAssetsInScreamBundle(BundleLoader bundleLoader) { bool v = bundleLoader.db.bundles.Length == bundleLoader.loadedBundles.Keys.Count; Debug.Log(v); List <AssetBundle> list = bundleLoader.loadedBundles.Values .Where(bundle => bundle != null) .Where(bundle => { return(bundle.AllAssetNames().Length == 0 || bundle.isStreamedSceneAssetBundle); }) .ToList(); Debug.Log(list.Count); foreach (AssetBundle assetBundle in list) { Debug.Log(assetBundle.name); } foreach (AssetBundle assetBundle in list) { Debug.Log(assetBundle.isStreamedSceneAssetBundle); } }
private static void getStatistic(Dictionary <string, HashSet <string> > map, BundleLoader bundleLoader) { bundleLoader.GetLoadedAssetBundles() .Where(bundle => bundle != null && !bundle.isStreamedSceneAssetBundle) .Take(40) .ToList() .ForEach(bundle => { bundle.GetAllAssetNames() .ToList() .ForEach(assetName => { Object asset = bundle.LoadAsset(assetName); if (asset == null) { Debug.LogError(assetName); return; } if (!map.ContainsKey(assetName.Split('.').Last())) { map.Add(assetName.Split('.').Last(), new HashSet <string>()); } map[assetName.Split('.').Last()].Add(asset.GetType() + ""); }); }); string t = ""; map.Keys.ToList() .ForEach(key => { t += key + "\n"; map[key].ToList() .ForEach(value => { t += ("----" + value + "\n"); }); }); Debug.LogError(t); }
public IEnumerator LoadAsync(BundleLoader bundleloader, BundleLoaderSharedObject blso, string bundleResName, LoadCallBackHandler loadCallBack, ResourceCallBackHander resCallBack, HandlerParam HP, bool loadAssets) { mBundleName = bundleResName; AssetBundleCreateRequest bundleRequest; string path = BundleLoader.LoadBundleAsyncFromSDCard(mBundleName); if (File.Exists(path)) { bundleRequest = AssetBundle.LoadFromFileAsync(path); yield return(bundleRequest); mAssetBundle = bundleRequest.assetBundle; } if (mAssetBundle == null) { #if UNITY_ANDROID && !_TEST if (BundleLoader.mStreamBundleList.Contains(mBundleName)) #endif { bundleRequest = BundleLoader.LoadBundleAsyncFromStreamingAssets(mBundleName); yield return(bundleRequest); mAssetBundle = bundleRequest.assetBundle; } #if UNITY_ANDROID if (mAssetBundle == null) { bundleRequest = BundleLoader.LoadBundleAsyncFromApkStreamingAssets(mBundleName); yield return(bundleRequest); mAssetBundle = bundleRequest.assetBundle; } #endif if (mAssetBundle == null) { // DebugConsole.sendmsgServer(mBundleName + "not loaded!"); bundleloader.RemoveAssetBundle(mBundleName); BundleManager.Instance.StartCoroutine(BundleLoader.LoadBundleFromWWW(bundleResName)); } } int startIdx = mBundleName.LastIndexOf("/"); int endIdx = mBundleName.LastIndexOf("."); try { assName = mBundleName.Substring(startIdx + 1, endIdx - startIdx - 1); } catch (System.Exception e) { } if (loadAssets && loadCallBack != null) { mMainObject = mAssetBundle.LoadAsset(assName); } if (resCallBack != null) { resCallBack(blso, bundleResName, mAssetBundle, loadCallBack, HP, loadAssets); } }
public static void RemoveFinishedLoader(BundleLoader l, string bundleName, Object[] assets, AssetBundle bundle) { InsertAssetToMap(bundleName, assets, bundle); LoadingList.Remove(l); }
public static void AddLoadingLoader(BundleLoader l) { LoadingList.Add(l); }