예제 #1
0
    public void UnLoadAssetBundle(string bundlePath)
    {
        FixedBundleFilePath(ref bundlePath);


        BundleCounter bc = null;

        if (bundleDicts.TryGetValue(bundlePath, out bc))
        {
            bc.count--;
            if (bc.count <= 0)
            {
                bc.asset.Unload(false);
                bundleDicts.Remove(bundlePath);
            }
        }
    }
예제 #2
0
    public AssetBundle LoadAssetBundle(string bundlePath)
    {
        FixedBundleFilePath(ref bundlePath);

        BundleCounter bc = null;

        if (bundleDicts.TryGetValue(bundlePath, out bc))
        {
            bc = bundleDicts [bundlePath];
            bc.count++;
        }
        else
        {
            AssetBundle ab = AssetBundle.LoadFromFile(mainfestParentPath + "/" + bundlePath);
            bc = new BundleCounter(ab, 1, bundlePath);
            bundleDicts [bundlePath] = bc;
        }
        return(bc.asset);
    }
예제 #3
0
    private IEnumerator LoadAssetBundleAsync(string bundlePath, System.Action <string, AssetBundle> act)
    {
        BundleCounter bc = null;

        if (bundleDicts.TryGetValue(bundlePath, out bc))
        {
            bc = bundleDicts [bundlePath];
            bc.count++;
        }
        else
        {
            AssetBundleCreateRequest request = AssetBundle.LoadFromFileAsync(mainfestParentPath + "/" + bundlePath);
            yield return(request);

            bc = new BundleCounter(request.assetBundle, 1, bundlePath);
            bundleDicts [bundlePath] = bc;
        }
        act(bundlePath, bc.asset);
    }