protected IEnumerator LoadSpriteRenderer(string assetBundleName, string assetName, SpriteRenderer setSprite = null) { Debug.Log("Start to load " + assetName + " at frame " + Time.frameCount); // Load asset from assetBundle. AssetBundleLoadAssetOperation request = AssetBundleManager.LoadAssetAsync(assetBundleName, assetName, typeof(GameObject)); if (request == null) { yield break; } yield return(StartCoroutine(request)); // Get the asset. GameObject prefab = request.GetAsset <GameObject> (); Debug.Log(assetName + (prefab == null ? " isn't" : " is") + " loaded successfully at frame " + Time.frameCount); if (setSprite != null && prefab != null) { setSprite.sprite = prefab.GetComponent <SpriteRenderer> ().sprite; } }
protected IEnumerator Load(string assetBundleName, string assetName) { Debug.Log("Start to load " + assetName + " at frame " + Time.frameCount); // Load asset from assetBundle. AssetBundleLoadAssetOperation request = AssetBundleManager.LoadAssetAsync(assetBundleName, assetName, typeof(GameObject)); if (request == null) { yield break; } yield return(StartCoroutine(request)); // Get the asset. GameObject prefab = request.GetAsset <GameObject> (); Debug.Log(assetName + (prefab == null ? " isn't" : " is") + " loaded successfully at frame " + Time.frameCount); if (prefab != null) { GameObject.Instantiate(prefab); } }
protected IEnumerator InstantiateGameObjectAsync(string assetBundleName, string assetName) { float startTime = Time.realtimeSinceStartup; AssetBundleLoadAssetOperation request = AssetBundleManager.LoadAssetAsync(assetBundleName, assetName, typeof(GameObject)); if (request == null) { yield break; } yield return(StartCoroutine(request)); // Get the asset. GameObject prefab = request.GetAsset <GameObject>(); if (prefab != null) { GameObject.Instantiate(prefab); } float elapsedTime = Time.realtimeSinceStartup - startTime; Debug.Log(assetName + (prefab == null ? " was not" : " was") + " loaded successfully in " + elapsedTime + " seconds"); }
private IEnumerator LoadMeshCoroutine(string path, Action <GameObject> callback) { var pathParts = path.Split('/'); var assetBundleName = pathParts[0].ToLower(); var assetName = pathParts[pathParts.Length - 1]; if (!LoaderManager.Instance.IsReady) { yield return(null); } AssetBundleLoadAssetOperation request = AssetBundleManager.LoadAssetAsync(assetBundleName, assetName, typeof(GameObject)); if (request == null) { Debug.LogError("Failed AssetBundleLoadAssetOperation on " + assetName + " from the AssetBundle " + assetBundleName + "."); yield break; } yield return(StartCoroutine(request)); callback.Invoke(request.GetAsset <GameObject>()); }
static public IEnumerator LoadJsonData(string assetBundleName, string assetName, System.Action <JsonData> result) { if (string.IsNullOrEmpty(assetBundleName) || string.IsNullOrEmpty(assetName)) { Debug.LogWarning("assetBundleName or assetName is empty"); result(null); yield break; } if (!Instance.isInitialized) { yield return(Instance.StartCoroutine(Instance.Initialize())); } AssetBundleLoadAssetOperation r = AssetBundleManager.LoadAssetAsync(assetBundleName, assetName, typeof(Object)); if (r == null) { result(null); yield break; } yield return(Instance.StartCoroutine(r)); TextAsset txt = r.GetAsset <TextAsset>(); if (!txt) { result(null); yield break; } JsonReader jReader = new JsonReader(txt.text); JsonData jData = JsonMapper.ToObject(jReader); result(jData); }
public IEnumerator LoadAssetBundleAsync(string assetPath) { if (m_resources.ContainsKey(assetPath)) { yield break; } string assetName = assetPath.Split('/') [assetPath.Split('/').Length - 1]; Debug.LogWarning(string.Format("Start to load asset \"{0}\" at frame {1}", assetName, Time.frameCount)); // Load asset from assetBundle. AssetBundleLoadAssetOperation request = GameSystemManager.Get <AssetBundleManager>().LoadAssetAsync(assetPath.ToLower() + ".assetbundle", assetName, typeof(Object)); if (request == null) { yield break; } yield return(StartCoroutine(request)); // Get the asset. Object asset = request.GetAsset <Object> (); Debug.LogWarning(string.Format("{0} to load asset \"{1}\" at frame {2}", asset == null ? "Failed" : "Succeeded", assetName, Time.frameCount)); Resource res = new Resource(); res.Res = (object)asset; res.CheckoutCount = 0; if (res.Res == null) { Debug.LogError("[ResourceManager] - Failed to find resource '" + assetName + "'"); } m_resources[assetPath] = res; }
protected IEnumerator InstantiateGameObjectAsync(string assetBundleName, string assetName) { // This is simply to get the elapsed time for this phase of AssetLoading. float startTime = Time.realtimeSinceStartup; // Load asset from assetBundle. AssetBundleLoadAssetOperation request = AssetBundleManager.LoadAssetAsync(assetBundleName, assetName, typeof(GameObject)); if (request == null) { yield break; } yield return(StartCoroutine(request)); // Get the asset. prefab = request.GetAsset <GameObject> (); //if (prefab != null) //GameObject.Instantiate(prefab); // Calculate and display the elapsed time. float elapsedTime = Time.realtimeSinceStartup - startTime; //Debug.Log(assetName + (prefab == null ? " was not" : " was")+ " loaded successfully in " + elapsedTime + " seconds" ); }
public IEnumerator LoadTexture(string assetBundleName, string assetName, System.Action <Texture> result) { if (string.IsNullOrEmpty(assetBundleName) || string.IsNullOrEmpty(assetName)) { Debug.LogWarning("assetBundleName or assetName is empty"); result(null); yield break; } if (!isInitialized) { yield return(StartCoroutine(Initialize())); } AssetBundleLoadAssetOperation r = AssetBundleManager.LoadAssetAsync(assetBundleName, assetName, typeof(Texture)); if (r == null) { result(null); yield break; } yield return(StartCoroutine(r)); Texture texture = r.GetAsset <Texture>(); //Debug.Log(texture); if (!texture) { result(null); yield break; } result(texture); }
private static IEnumerable LoadUIAsset(string assetBundleName, string assetName, Action <RectTransform> assign) { AssetBundleLoadAssetOperation request = AssetBundleManager.LoadAssetAsync(assetBundleName, assetName, typeof(GameObject)); if (request == null) { throw new NullReferenceException($"Request for {assetName} in {assetBundleName} assetbundle failed: Null request."); } yield return(request); GameObject go = request.GetAsset <GameObject>(); if (go == null) { throw new NullReferenceException($"Request for {assetName} in {assetBundleName} assetbundle failed: Null GameObject."); } var prefab = go.GetComponent <RectTransform>(); if (prefab == null) { throw new NullReferenceException($"Request for {assetName} in {assetBundleName} assetbundle failed: Null RectTansform."); } assign(prefab); }
public IEnumerator LoadPrefab(string prefabName, LoadBundleAssetCallback <GameObject> callBack) { string bundleName = "Asset/" + prefabName + ".common"; string assetName = System.IO.Path.GetFileNameWithoutExtension(bundleName); if (_ResFromBundle) { AssetBundleLoadAssetOperation request = AssetBundleManager.LoadAssetAsync(bundleName.ToLower(), assetName, typeof(GameObject)); if (request == null) { Debug.LogError("Failed AssetBundleLoadAssetOperation on " + assetName + " from the AssetBundle " + bundleName + "."); yield break; } yield return(StartCoroutine(request)); GameObject prefab = request.GetAsset <GameObject>(); Debug.Log("LoadPrefab:" + prefabName); var instanceGO = GameObject.Instantiate(prefab); callBack.Invoke(assetName, instanceGO, null); } else { Debug.Log("LoadPrefab:" + bundleName); GameObject resData = Resources.Load <GameObject>(prefabName); var instanceGO = GameObject.Instantiate(resData); Debug.Log("LoadPrefab instanceGO:" + prefabName); if (callBack != null) { callBack.Invoke(assetName, instanceGO, null); } Debug.Log("LoadPrefab callBack.Invoke:" + prefabName); } }
private static IEnumerator GetAssetFromFileCo <T>(AssetBundleLoadAssetOperation op, Action <T> callback) where T : Object { yield return(op); callback(op.GetAsset <T>()); }
IEnumerator Login(string userID, string pletformID = "", LoginType loginType = LoginType.GuestLogin) { Debug.Log("로그인 시작"); loginPanel.SetActive(false); //로그인 시 유저 데이터 구성부분 WWWForm form = new WWWForm(); form.AddField("userID", userID, System.Text.Encoding.UTF8); //테스트 아이디로 로그인한다. string googleID = ""; if (PlayerPrefs.HasKey("google")) { googleID = PlayerPrefs.GetString("google"); } else { if (loginType == LoginType.GoogleLogin) { googleID = pletformID; } } string facebookID = ""; if (PlayerPrefs.HasKey("facebook")) { facebookID = PlayerPrefs.GetString("facebook"); } else { if (loginType == LoginType.FacebookLogin) { facebookID = pletformID; } } tipMessageText.text = "로그인 정보를 내려받는 중.."; form.AddField("google", googleID, System.Text.Encoding.UTF8); form.AddField("facebook", facebookID, System.Text.Encoding.UTF8); form.AddField("deviceModel", SystemInfo.deviceModel); form.AddField("deviceID", SystemInfo.deviceUniqueIdentifier); form.AddField("type", (int)loginType); string result = ""; string php = "Login.php"; yield return(StartCoroutine(WebServerConnectManager.Instance.WWWCoroutine(php, form, x => result = x))); JsonData jsonData = ParseCheckDodge(result); PlayerPrefs.SetString("userID", JsonParser.ToString(jsonData["id"].ToString())); if (loginType == LoginType.GoogleLogin) { PlayerPrefs.SetString("google", JsonParser.ToString(jsonData["google"].ToString())); } if (loginType == LoginType.FacebookLogin) { PlayerPrefs.SetString("facebook", JsonParser.ToString(jsonData["facebook"].ToString())); } // 아틀라스 캐싱 string atlasName = "Atlas_Product"; AssetBundleLoadAssetOperation r = AssetBundleManager.LoadAssetAsync("sprite/product", atlasName, typeof(UnityEngine.U2D.SpriteAtlas)); yield return(StartCoroutine(r)); UnityEngine.U2D.SpriteAtlas atlas = r.GetAsset <UnityEngine.U2D.SpriteAtlas>(); if (atlas != null) { if (!AssetLoader.cachedAtlasDic.ContainsKey(atlasName)) { AssetLoader.cachedAtlasDic.Add(atlasName, atlas); } } string atlasName2 = "Atlas_Material"; AssetBundleLoadAssetOperation r2 = AssetBundleManager.LoadAssetAsync("sprite/material", atlasName2, typeof(UnityEngine.U2D.SpriteAtlas)); yield return(StartCoroutine(r2)); UnityEngine.U2D.SpriteAtlas atlas2 = r2.GetAsset <UnityEngine.U2D.SpriteAtlas>(); if (atlas2 != null) { if (!AssetLoader.cachedAtlasDic.ContainsKey(atlasName2)) { AssetLoader.cachedAtlasDic.Add(atlasName2, atlas2); } } //// 게임 데이타 초기화 끝날 때 까지 대기 //while (!GameDataManager.isInitialized) // yield return null; if (User.Instance) { User.Instance.InitUserData(jsonData); } Debug.Log("유저 데이터 초기화"); while (!User.isInitialized) { yield return(null); } Debug.Log("완료"); // 유저 데이터 초기화 시작 StartCoroutine(UserDataManager.Instance.Init()); // 유저 데이터 초기화 완료 했는가 체크 while (!UserDataManager.isInitialized) { yield return(null); } tipMessageText.text = "왕국으로 진입중.."; Debug.Log("Login UserID : " + JsonParser.ToString(jsonData["id"])); //enterButton.SetActive(true); //if (onFadeOutStart != null) // onFadeOutStart(); ////페이드아웃 기다리는 시간 //yield return new WaitForSeconds(1.5f); yield return(StartCoroutine(LoadingManager.FadeOutScreen())); string nextSceneBundleName = "scene/lobby"; string nextSceneName = "Lobby"; AssetBundleLoadOperation operation = AssetBundleManager.LoadLevelAsync(nextSceneBundleName, nextSceneName, true); //// 몬스터 풀 초기화 끝났는가 체크 //while (!MonsterPool.Instance) // yield return null; //while (!MonsterPool.Instance.isInitialization) // yield return null; //while (!Battle.Instance || !Battle.Instance.isInitialized) // yield return null; while (!operation.IsDone()) { yield return(null); } versionText.gameObject.SetActive(false); messagePanel.SetActive(false); StopCoroutine(messageCoroutine()); //while (!UILoginManager.isFinished) // yield return null; Scene lobby = SceneManager.GetSceneByName("Lobby"); Scene login = SceneManager.GetSceneByName("Login"); Scene preLogin = SceneManager.GetSceneByName("PreLogin"); SceneManager.SetActiveScene(lobby); SceneManager.UnloadSceneAsync(login); SceneManager.UnloadSceneAsync(preLogin); }
public IEnumerator LoadSprite(string assetBundleName, string atlasName, string spriteName, System.Action <Sprite> result) { if (string.IsNullOrEmpty(assetBundleName) || string.IsNullOrEmpty(spriteName) || string.IsNullOrEmpty(atlasName)) { Debug.LogWarning("assetBundleName or assetName is empty"); result(null); yield break; } if (!isInitialized) { yield return(StartCoroutine(Initialize())); } SpriteAtlas atlas = null; if (cachedAtlasDic.ContainsKey(atlasName)) { atlas = cachedAtlasDic[atlasName]; } if (!atlas) { AssetBundleLoadAssetOperation r = AssetBundleManager.LoadAssetAsync(assetBundleName, atlasName, typeof(SpriteAtlas)); if (r == null) { result(null); yield break; } yield return(StartCoroutine(r)); //Debug.Log(r.IsDone()); atlas = r.GetAsset <SpriteAtlas>(); if (atlas != null) { if (!cachedAtlasDic.ContainsKey(atlasName)) { cachedAtlasDic.Add(atlasName, atlas); } //Debug.Log("스프라이트 수량 " + atlas.spriteCount); } } Sprite sprite = null; if (atlas != null) { sprite = atlas.GetSprite(spriteName); } //SpriteAtlasManager.atlasRequested += // //AssetBundleCreateRequest bundleReq = AssetBundle.LoadFromFileAsync(path); //yield return bundleReq; //AssetBundle bundle = bundleReq.assetBundle; //if (bundle == null) //{ // Debug.LogError("Failed to load Asset Bundle at " + path); // yield break; //} //AssetBundleRequest atlasReq = bundle.LoadAssetAsync<SpriteAtlas>(atlasName); //yield return atlasReq; //SpriteAtlas atlas = (SpriteAtlas)atlasReq.asset as SpriteAtlas; //Sprite[] sprites = new Sprite[ //callback(bundle, ); //// //AssetBundleLoadAssetOperation r = AssetBundleManager.LoadAssetAsync(assetBundleName, assetName, typeof(Sprite)); //yield return StartCoroutine(r); //Sprite sprite = r.GetAsset<Sprite>(); //Debug.Log(texture); if (!sprite) { result(null); yield break; } result(sprite); }
private void UpdateLoadAssets() { AssetBundleLoadAssetOperation operation = null; for (int i = 0; i < m_InProgressOperations.Count;) { operation = m_InProgressOperations[i]; if (operation.IsDone()) { // 如果完成直接移除,避免后面回调方法中上层逻辑错误导致不停Update m_InProgressOperations.RemoveAt(i); string key = AssetKey(operation.assetBundleName, operation.assetName, operation.type); if (string.IsNullOrEmpty(operation.Error)) { AssetCache asset = CacheAsset(key, operation.GetAsset()); if (asset != null) { asset.assetbundleVariant = operation.assetBundleVariant; m_CallbackTemp.Add(key); } else { AssetBundleManager.UnloadAssetBundle(operation.assetBundleVariant); Callback(key, null, string.Format("[{0} no asset error!]", key)); } } else { if (m_AssetCaches.TryGetValue(key, out AssetCache cache)) { cache.assetbundleVariant = operation.assetBundleVariant; } RemoveCachedAsset(key); Callback(key, null, operation.Error); } } else { i++; } } //todo 同一帧可能返回多个,这里还是需要保护一下, while (m_CallbackTemp.Count > 0) { string key = m_CallbackTemp[0]; if (m_AssetCaches.TryGetValue(key, out AssetCache cache)) { if (cache != null && cache.obj != null) { Callback(key, cache.obj, string.Empty); } else { Debug.LogErrorFormat("{0} is Null", key); } } m_CallbackTemp.RemoveAt(0); } }
// Download dữ liệu dựa theo id public override IEnumerator DownloadData() { // Download am thanh, text, #region DownloadContent AssetBundleLoadAssetOperation request = BundleManager.LoadAssetAsync(data.audioBundle[0], data.audioBundle[1], typeof(AudioClip)); if (request == null) { yield break; } yield return(StartCoroutine(request)); data.introAudio = request.GetAsset <AudioClip>(); //Debug.Log(data.introAudio); //request = null; request = BundleManager.LoadAssetAsync(data.audioBundle[2], data.audioBundle[3], typeof(AudioClip)); //Debug.Log(request); if (request == null) { yield break; } yield return(StartCoroutine(request)); data.detailAudio = request.GetAsset <AudioClip>(); //Debug.Log(data.detailAudio); //======================= // Download text================ Debug.Log(data.textBundle[0]); if (!data.textBundle[0].Trim().Equals("")) { request = BundleManager.LoadAssetAsync(data.textBundle[0], data.textBundle[1], typeof(TextAsset)); if (request == null) { yield break; } yield return(StartCoroutine(request)); //Debug.Log(request.GetAsset<TextAsset>()); data.text = request.GetAsset <TextAsset>(); Debug.Log(data.text); } // ============================== // Download sprites================ int size = data.spriteBundle.Length - 1; for (int i = 0; i < size; i += 2) { request = BundleManager.LoadAssetAsync(data.spriteBundle[i], data.spriteBundle[i + 1], typeof(Sprite)); if (request == null) { yield break; } yield return(StartCoroutine(request)); data.sprites.Add(request.GetAsset <Sprite>()); } // ===================================== BundleManager.UnloadBundle(data.audioBundle[0]); data.imgTime = time; #endregion }
// Download du lieu thu number IEnumerator DownloadData(int number) { if (number < numberOfData) { #region DownloadContent // Download audio================ yield return(StartCoroutine(data[number].GetAudio(1))); AssetBundleLoadAssetOperation request = BundleManager.LoadAssetAsync(data[number].audioBundle[0], data[number].audioBundle[1], typeof(AudioClip)); if (request == null) { yield break; } yield return(StartCoroutine(request)); data[number].introAudio = request.GetAsset <AudioClip>(); Debug.Log(data[number].audioBundle); //request = null; request = BundleManager.LoadAssetAsync(data[number].audioBundle[2], data[number].audioBundle[3], typeof(AudioClip)); //Debug.Log(request); if (request == null) { yield break; } yield return(StartCoroutine(request)); data[number].detailAudio = request.GetAsset <AudioClip>(); //Debug.Log(data.detailAudio); //======================= // Download text================ //bundleName = ""; //assetName = ""; //request = null; //DBManager.Instance.GetText(ids[number], ref bundleName, ref assetName); //request = BundleManager.LoadAssetAsync(bundleName, assetName, typeof(TextAsset)); //if (request == null) // yield break; //yield return StartCoroutine(request); ////Debug.Log(request.GetAsset<TextAsset>()); //temp.text = request.GetAsset<TextAsset>(); //Debug.Log(temp.text); // ============================== // Download sprites================ yield return(StartCoroutine(data[number].GetSprites())); int size = data[number].spriteBundle.Length - 1; for (int i = 0; i < size; i += 2) { request = BundleManager.LoadAssetAsync(data[number].spriteBundle[i], data[number].spriteBundle[i + 1], typeof(Sprite)); if (request == null) { yield break; } yield return(StartCoroutine(request)); data[number].sprites.Add(request.GetAsset <Sprite>()); } Debug.Log(number + " - " + data[number].sprites.Count); BundleManager.UnloadBundle(data[number].audioBundle[0]); #endregion } }
static public IEnumerator LoadTextAssets() { s_dicTextAsset.Clear(); if (AssetBundleManager.SimulateAssetBundleInEditor == true) { string[] arrSettingData = AssetDatabase.GetAssetPathsFromAssetBundle("setting_data"); if (arrSettingData == null) { yield break; } string stringData = string.Empty; for (int i = 0; i < arrSettingData.Length; ++i) { stringData = Path.GetFileName(arrSettingData[i]); stringData = stringData.Replace(".json", ""); TextAsset assetData = AssetDatabase.LoadAssetAtPath <TextAsset>(arrSettingData[i]); s_dicTextAsset.Add(stringData, assetData.text); } yield break; } { while (AssetBundleManager.AssetBundleManifestObject == null) { yield return(new WaitForSeconds(1f)); } AssetBundleManager.LoadAssetBundle("setting_data"); string strError = string.Empty; LoadedAssetBundle loadBundle = AssetBundleManager.GetLoadedAssetBundle("setting_data", out strError); while (loadBundle == null) { yield return(new WaitForSeconds(0.1f)); loadBundle = AssetBundleManager.GetLoadedAssetBundle("setting_data", out strError); } string[] strAssetData = loadBundle.m_AssetBundle.GetAllAssetNames(); if (strAssetData != null) { string stringData = string.Empty; for (int i = 0; i < strAssetData.Length; ++i) { stringData = Path.GetFileName(strAssetData[i]); stringData = stringData.Replace(".json", ""); stringData = stringData.ToUpper(); AssetBundleLoadAssetOperation operation = AssetBundleManager.LoadAssetAsync("setting_data", stringData, typeof(TextAsset)); if (operation != null) { while (operation.IsDone() == false) { yield return(new WaitForEndOfFrame()); } TextAsset assetData = operation.GetAsset <TextAsset>(); s_dicTextAsset.Add(stringData, assetData.text); } AssetBundleManager.UnloadAssetBundle("setting_data"); } } } }
private bool LoadCategoryInfoList( string assetBundleName, string assetName, Dictionary <string, int> dictEnumSrc) { if (!AssetBundleCheck.IsFile(assetBundleName, assetName)) { Debug.LogError((object)("読み込みエラー\r\nassetBundleName:" + assetBundleName + "\tassetName:" + assetName)); return(false); } AssetBundleLoadAssetOperation loadAssetOperation = AssetBundleManager.LoadAsset(assetBundleName, assetName, typeof(TextAsset), (string)null); if (loadAssetOperation == null) { Debug.LogError((object)("読み込みエラー\r\nassetName:" + assetName)); return(false); } TextAsset asset = loadAssetOperation.GetAsset <TextAsset>(); if (Object.op_Equality((Object)null, (Object)asset)) { Debug.LogError((object)"ありえない"); return(false); } string[,] data; YS_Assist.GetListString(asset.get_text(), out data); int length1 = data.GetLength(0); int length2 = data.GetLength(1); this.dictCategory.Clear(); if (length1 != 0 && length2 != 0) { for (int index = 0; index < length1; ++index) { ShapeInfoBase.CategoryInfo categoryInfo = new ShapeInfoBase.CategoryInfo(); categoryInfo.Initialize(); int key = int.Parse(data[index, 0]); categoryInfo.name = data[index, 1]; int num = 0; if (!dictEnumSrc.TryGetValue(categoryInfo.name, out num)) { Debug.LogWarning((object)("SrcBone【" + categoryInfo.name + "】のIDが見つかりません")); } else { categoryInfo.id = num; categoryInfo.use[0][0] = !(data[index, 2] == "0"); categoryInfo.use[0][1] = !(data[index, 3] == "0"); categoryInfo.use[0][2] = !(data[index, 4] == "0"); if (categoryInfo.use[0][0] || categoryInfo.use[0][1] || categoryInfo.use[0][2]) { categoryInfo.getflag[0] = true; } categoryInfo.use[1][0] = !(data[index, 5] == "0"); categoryInfo.use[1][1] = !(data[index, 6] == "0"); categoryInfo.use[1][2] = !(data[index, 7] == "0"); if (categoryInfo.use[1][0] || categoryInfo.use[1][1] || categoryInfo.use[1][2]) { categoryInfo.getflag[1] = true; } categoryInfo.use[2][0] = !(data[index, 8] == "0"); categoryInfo.use[2][1] = !(data[index, 9] == "0"); categoryInfo.use[2][2] = !(data[index, 10] == "0"); if (categoryInfo.use[2][0] || categoryInfo.use[2][1] || categoryInfo.use[2][2]) { categoryInfo.getflag[2] = true; } List <ShapeInfoBase.CategoryInfo> categoryInfoList = (List <ShapeInfoBase.CategoryInfo>)null; if (!this.dictCategory.TryGetValue(key, out categoryInfoList)) { categoryInfoList = new List <ShapeInfoBase.CategoryInfo>(); this.dictCategory[key] = categoryInfoList; } categoryInfoList.Add(categoryInfo); } } } AssetBundleManager.UnloadAssetBundle(assetBundleName, true, (string)null, false); return(true); }
public static List <ExcelData.Param> LoadExcelData( string _strAssetPath, string _strFileName, int sCell, int sRow, int eCell, int eRow, bool _isWarning = true) { if (!GlobalMethod.AssetFileExist(_strAssetPath, _strFileName, string.Empty)) { if (_isWarning) { GlobalMethod.DebugLog("excel : [" + _strAssetPath + "][" + _strFileName + "]は見つかりません", 1); } return((List <ExcelData.Param>)null); } AssetBundleLoadAssetOperation loadAssetOperation = AssetBundleManager.LoadAsset(_strAssetPath, _strFileName, typeof(ExcelData), (string)null); AssetBundleManager.UnloadAssetBundle(_strAssetPath, true, (string)null, false); if (loadAssetOperation.IsEmpty()) { if (_isWarning) { GlobalMethod.DebugLog("excel : [" + _strFileName + "]は[" + _strAssetPath + "]の中に入っていません", 1); } return((List <ExcelData.Param>)null); } GlobalMethod.excelData = loadAssetOperation.GetAsset <ExcelData>(); GlobalMethod.cell.Clear(); foreach (ExcelData.Param obj in GlobalMethod.excelData.list) { GlobalMethod.cell.Add(obj.list[sCell]); } GlobalMethod.row.Clear(); foreach (string str in GlobalMethod.excelData.list[sRow].list) { GlobalMethod.row.Add(str); } List <string> cell1 = GlobalMethod.cell; List <string> row1 = GlobalMethod.row; ExcelData.Specify specify1 = new ExcelData.Specify(eCell, eRow); ExcelData.Specify specify2 = new ExcelData.Specify(cell1.Count, row1.Count); GlobalMethod.excelParams.Clear(); if ((long)(uint)specify1.cell > (long)specify2.cell || (long)(uint)specify1.row > (long)specify2.row) { return((List <ExcelData.Param>)null); } if (specify1.cell < GlobalMethod.excelData.list.Count) { for (int cell2 = specify1.cell; cell2 < GlobalMethod.excelData.list.Count && cell2 <= specify2.cell; ++cell2) { ExcelData.Param obj = new ExcelData.Param(); if (specify1.row < GlobalMethod.excelData.list[cell2].list.Count) { obj.list = new List <string>(); for (int row2 = specify1.row; row2 < GlobalMethod.excelData.list[cell2].list.Count && row2 <= specify2.row; ++row2) { obj.list.Add(GlobalMethod.excelData.list[cell2].list[row2]); } } GlobalMethod.excelParams.Add(obj); } } return(GlobalMethod.excelParams); }
public IEnumerator DownLoadContent(bool isSingle = false) { if (data == null) { data = new PictureData(); data.id = id; isDownloading = true; #region Download Island Content yield return(StartCoroutine(data.GetAudio(1))); AssetBundleLoadAssetOperation request = BundleManager.LoadAssetAsync(data.audioBundle[0], data.audioBundle[1], typeof(AudioClip)); if (request == null) { yield break; } yield return(StartCoroutine(request)); data.introAudio = request.GetAsset <AudioClip>(); request = BundleManager.LoadAssetAsync(data.audioBundle[2], data.audioBundle[3], typeof(AudioClip)); Debug.Log(request); if (request == null) { yield break; } yield return(StartCoroutine(request)); data.detailAudio = request.GetAsset <AudioClip>(); // ===================================== //// Download text================ //bundleName = ""; //assetName = ""; //request = null; //DBManager.Instance.GetText(id, ref bundleName, ref assetName); //request = BundleManager.LoadAssetAsync(bundleName, assetName, typeof(TextAsset)); //if (request == null) // yield break; //yield return StartCoroutine(request); ////Debug.Log(request.GetAsset<TextAsset>()); //data.text = request.GetAsset<TextAsset>(); //// ===================================== // Download sprites================ yield return(StartCoroutine(data.GetSprites())); int size = data.spriteBundle.Length - 1; for (int i = 0; i < size; i += 2) { request = BundleManager.LoadAssetAsync(data.spriteBundle[i], data.spriteBundle[i + 1], typeof(Sprite)); if (request == null) { yield break; } yield return(StartCoroutine(request)); data.sprites.Add(request.GetAsset <Sprite>()); } // ===================================== data.imgTime = time; #endregion isDownloading = false; } isReady = true; if (!isSingle) { EventManager.Instance.PostNotification("OnDownloadIsland", this, order + 1); } }
public static void GetAssetFromFile <T>(string filePath, Action <T> callback) where T : Object { AssetBundleLoadAssetOperation op = AssetBundleManager.LoadAssetAsync(filePath, "mainAsset", typeof(T)); callback(op.GetAsset <T>()); }
public static void LoadSprite( string assetBundleName, string assetName, Image image, bool isTexSize, string spAnimeName = null, string manifest = null, string spAnimeManifest = null) { AssetBundleLoadAssetOperation loadAssetOperation = AssetBundleManager.LoadAsset(assetBundleName, assetName, typeof(Sprite), manifest); Sprite asset1 = loadAssetOperation.GetAsset <Sprite>(); if (Object.op_Equality((Object)asset1, (Object)null)) { Texture2D asset2 = loadAssetOperation.GetAsset <Texture2D>(); asset1 = Sprite.Create(asset2, new Rect(0.0f, 0.0f, (float)((Texture)asset2).get_width(), (float)((Texture)asset2).get_height()), Vector2.get_zero()); } image.set_sprite(asset1); RectTransform rectTransform = ((Graphic)image).get_rectTransform(); Vector2 vector2_1; if (isTexSize) { Rect rect1 = asset1.get_rect(); double width = (double)((Rect) ref rect1).get_width(); Rect rect2 = asset1.get_rect(); double height = (double)((Rect) ref rect2).get_height(); vector2_1 = new Vector2((float)width, (float)height); } else { vector2_1 = rectTransform.get_sizeDelta(); } Vector2 vector2_2 = vector2_1; if (!spAnimeName.IsNullOrEmpty()) { Animator component = (Animator)((Component)image).GetComponent <Animator>(); ((Behaviour)component).set_enabled(true); component.set_runtimeAnimatorController(AssetBundleManager.LoadAsset(assetBundleName, spAnimeName, typeof(RuntimeAnimatorController), (string)null).GetAsset <RuntimeAnimatorController>()); Func <float, float, float> func1 = (Func <float, float, float>)((x, y) => x / y); Func <float, float, bool> func2 = (Func <float, float, bool>)((a, b) => (double)a > (double)b && Mathf.FloorToInt(a - 1f) > 0); float num1 = func1((float)vector2_2.x, (float)vector2_2.y); float num2 = func1((float)vector2_2.y, (float)vector2_2.x); if (func2(num1, num2)) { rectTransform.set_sizeDelta(new Vector2((float)vector2_2.y, (float)vector2_2.y)); } else if (func2(num2, num1)) { rectTransform.set_sizeDelta(new Vector2((float)vector2_2.x, (float)vector2_2.x)); } else { rectTransform.set_sizeDelta(new Vector2((float)vector2_2.x, (float)vector2_2.y)); } AssetBundleManager.UnloadAssetBundle(assetBundleName, false, spAnimeManifest, false); } else { rectTransform.set_sizeDelta(new Vector2((float)vector2_2.x, (float)vector2_2.y)); } AssetBundleManager.UnloadAssetBundle(assetBundleName, false, manifest, false); }