public void LoadAsset(string assetName, string bundleName, Action <string, AssetBundle> onComplete) { AssetLoadRequest request = null; if (requests.TryGetValue(assetName, out request)) { request.onComplete += onComplete; return; } AssetLoadRequest newRequest = new AssetLoadRequest(); newRequest.onComplete += onComplete; newRequest.AssetName = assetName; Bundle bundle = GetBundle(bundleName); if (bundle == null) { bundle = DownLoadBundle(bundleName); } newRequest.AddDependentBundle(bundle); string[] dependencyBundleNames = manifest.GetAllDependencies(bundleName); foreach (var name in dependencyBundleNames) { Bundle dependBundle = GetBundle(name); if (dependBundle == null) { dependBundle = DownLoadBundle(name); } newRequest.AddDependentBundle(dependBundle); } requests.Add(assetName, newRequest); }
public void LoadAsset(string assetName, string bundleName, Action<string, AssetBundle> onComplete) { AssetLoadRequest request = null; if (requests.TryGetValue(assetName, out request)) { request.onComplete += onComplete; return; } AssetLoadRequest newRequest = new AssetLoadRequest(); newRequest.onComplete += onComplete; newRequest.AssetName = assetName; Bundle bundle = GetBundle(bundleName); if (bundle == null) { bundle = DownLoadBundle(bundleName); } newRequest.AddDependentBundle(bundle); string[] dependencyBundleNames = manifest.GetAllDependencies(bundleName); foreach (var name in dependencyBundleNames) { Bundle dependBundle = GetBundle(name); if (dependBundle == null) { dependBundle = DownLoadBundle(name); } newRequest.AddDependentBundle(dependBundle); } requests.Add(assetName, newRequest); }