Esempio n. 1
0
    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);
    }
Esempio n. 2
0
    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);
    }