//코루틴 함수. 에셋 번들을 로드하여 Dictionary에 저장하는 역할을 함 + 생성 public IEnumerator LoadFromFileAsync(string url, string assetName, bool removeAll) { if (this.IsVersionAdded(url, assetName)) { yield return(null); } else { string keyName = this.MakeKeyName(url, assetName); Debug.Log(keyName); AssetBundleCreateRequest req = AssetBundle.LoadFromFileAsync(keyName); yield return(req); //AssetBundle ab = req.assetBundle; //노드를 만들어서 데이터를 대입하여 초기화하고 dictionary에 저장함 AssetBundleNode node = new AssetBundleNode(url, assetName, removeAll, req.assetBundle); dicAssetBundle.Add(keyName, node); IstKeyName.Add(keyName); ////아마 assetName 마다 차별화 해둬야 할 거임. Ex) Item, Human, etc. //string[] bundleNames = ab.GetAllAssetNames(); //foreach (string path in bundleNames) //{ // StartCoroutine(this.LoadFromABasync_Item(path, ab)); //} //this.RemoveAllAssetBundles(); } }
public IEnumerator LoadAssetBundle(string url, int version, bool removeAll, float lifeTime = 0.0f, string bundleName = null) { string keyName = this.MakeKeyName(url, version); while (!Caching.ready) { yield return(null); } if (this.isVersionAdded(url, version)) { timeManager.ResetLifeTime(keyName); } else { using (UnityWebRequest uwr = UnityWebRequestAssetBundle.GetAssetBundle(url, (uint)version, 0)) { var operation = uwr.SendWebRequest(); while (!operation.isDone) { yield return(null); UI_StartManager.instance.SetDownLoadUIProgressbarValue(operation.progress, bundleName); } if (uwr.isNetworkError || uwr.isHttpError) { UI_StartManager.instance.ShowErrorUI("네트워크 오류로 인해 다운로드에 실패하였습니다."); } else { AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(uwr); //var materials = bundle.LoadAllAssets<Material>(); //foreach (Material m in materials) //{ // var shaderName = m.shader.name; // var newShader = Shader.Find(shaderName); // if (newShader != null) // { // m.shader = newShader; // } // else // { // Debug.LogWarning("unable to refresh shader: " + shaderName + " in material " + m.name); // } //} AssetBundleNode node = new AssetBundleNode(url, version, removeAll, bundle); dicAssetBundle.Add(keyName, node); lstKeyName.Add(keyName); if (lifeTime > 0.0f) { timeManager.SetLifeTime(keyName, lifeTime); } } } } yield return(null); }
private void SearchDirectory(string path) { // GetFileName(path); DirectoryInfo root = new DirectoryInfo(path); foreach (DirectoryInfo d in root.GetDirectories()) { string _atlasRelativePath = d.FullName.Split(new string[] { "Export/" }, StringSplitOptions.RemoveEmptyEntries)[1]; if (d.GetDirectories().Length == 0) { AssetBundleNode node = new AssetBundleNode { AssetBundleName = d.Name, AssetBundlePath = _atlasRelativePath }; AtlasPathNodeList.Add(node); } else { SearchDirectory(d.FullName); } } }