private void LoadDependencyBundlesAsync(Action onAllLoaded) { var dependencyBundleNames = ResData.Instance.GetDirectDependencies(Name); var loadedCount = 0; if (dependencyBundleNames.Length == 0) { onAllLoaded(); } foreach (var dependencyBundleName in dependencyBundleNames) { mResLoader.LoadAsync <AssetBundle>(dependencyBundleName, dependBundle => { loadedCount++; if (loadedCount == dependencyBundleNames.Length) { onAllLoaded(); } }); } }
private IEnumerator Start() { yield return(new WaitForSeconds(5)); mResLoader.LoadSync <Texture2D>("resources://pic1"); yield return(new WaitForSeconds(2)); Debug.Log("Start load:" + Time.time); mResLoader.LoadAsync <AudioClip>("resources://getcoin", callback => { Debug.Log(callback.name); Debug.Log("end load:" + Time.time); }); yield return(new WaitForSeconds(2)); mResLoader.LoadSync <AudioClip>("resources://home"); yield return(new WaitForSeconds(2)); mResLoader.LoadSync <AudioClip>("resources://Audio/getcoin"); yield return(new WaitForSeconds(3)); var homePanelPrefab = mResLoader.LoadSync <GameObject>("resources://HomePanel"); yield return(new WaitForSeconds(3)); mResLoader.ReleaseAll(); Debug.Log(homePanelPrefab == null); }
public override void LoadAsync <T>() { State = ResState.Loading; mResLoader.LoadAsync <AssetBundle>(mOwnerBundleName, ownerBundle => { if (ResMgr.IsSimulationModeLogic) { #if UNITY_EDITOR var assetPaths = UnityEditor.AssetDatabase.GetAssetPathsFromAssetBundleAndAssetName(mOwnerBundleName, Name); Asset = UnityEditor.AssetDatabase.LoadAssetAtPath <Object>(assetPaths[0]); State = ResState.Loaded; #endif } else { var assetBundleRequest = ownerBundle.LoadAssetAsync <T>(Name); assetBundleRequest.completed += operation => { Asset = assetBundleRequest.asset; State = ResState.Loaded; }; } }); }