public override void LoadAsync() { 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(Name); assetBundleRequest.completed += operation => { Asset = assetBundleRequest.asset; State = ResState.Loaded; }; } }); }
// Use this for initialization void Start() { mResLoader.LoadAsync <AssetBundle>("gameobject", loadedBundle => { var gameObj = loadedBundle.LoadAsset <GameObject>("gameobject"); Instantiate(gameObj); }); }
// Use this for initialization IEnumerator Start() { yield return(new WaitForSeconds(2f)); mResLoader.LoadAsync <AudioClip>("resources://hit", hitClip => { Debug.Log(hitClip.name); Debug.Log(Time.deltaTime); }); Debug.Log(Time.deltaTime); mResLoader.LoadSync <GameObject>("resources://HomePanel"); yield return(new WaitForSeconds(2f)); mResLoader.LoadSync <AudioClip>("resources://bgm"); mResLoader.LoadSync <AudioClip>("resources://Audio/hit"); yield return(new WaitForSeconds(5f)); mResLoader.ReleaseAll(); }
private void LoadDependencyBundleAsync(Action onAllLoaded) { int loadedCount = 0; var dependencyBundleNames = ResData.Instance.GetDirectDependencies(Name); if (dependencyBundleNames.Length == 0) { onAllLoaded(); } foreach (var dependencyBundleName in dependencyBundleNames) { mResLoader.LoadAsync <AssetBundle>(dependencyBundleName, dependBundle => { loadedCount++; if (loadedCount == dependencyBundleNames.Length) { onAllLoaded(); } }); } }