Example #1
0
    /// <summary>
    /// 引用计数为 0 时,将数据移除
    /// </summary>
    /// <param name="assetBundleName"></param>
    public void FreeAssetBundle(string assetBundleName)
    {
        Element <AssetBundleData> assetBundleData = null;

        AssetBundleDataCache.TryGetValue(assetBundleName, out assetBundleData);
        if (assetBundleData != null)
        {
            m_assertBundlePool.Push(assetBundleData);
            AssetBundleDataCacheRemvoe(assetBundleName);
        }
    }
Example #2
0
    /// <summary>
    /// 释放资源
    /// </summary>
    /// <param name="assetBundleName"></param>
    // public void UnloadAssetBundle(string assetBundleName)
    // {
    //     UnloadAssetBundleInternal(assetBundleName);
    //     UnLoadDependencies(assetBundleName);
    // }

    // /// <summary>
    // /// 释放依赖资源
    // /// </summary>
    // /// <param name="assetBundleName"></param>
    // public void UnLoadDependencies(string assetBundleName)
    // {
    //     string[] dependencies = null;
    //     if (!DependCache.TryGetValue(assetBundleName, out dependencies))
    //     {
    //         return;
    //     }

    //     for (int i = 0; i < dependencies.Length; ++i)
    //     {
    //         UnloadAssetBundleInternal(dependencies[i]);
    //     }
    // }

    // /// <summary>
    // /// 释放特定名资源
    // /// </summary>
    // /// <param name="assetBundleName"></param>
    // public void UnloadAssetBundleInternal(string assetBundleName)
    // {
    //     Element<AssetBundleData> assetBundleData = null;
    //     if (AssetBundleDataCache.TryGetValue(assetBundleName, out assetBundleData))
    //     {
    //assetBundleData.baseElement.Release();
    //     }
    // }

    /// <summary>
    /// 根据资源名获取资源数据
    /// </summary>
    /// <param name="assetBundleName"></param>
    /// <returns></returns>
    public AssetBundleData GetAssetBundleData(string assetBundleName)
    {
        Element <AssetBundleData> assetBundleData = null;

        AssetBundleDataCache.TryGetValue(assetBundleName, out assetBundleData);
        if (assetBundleData != null)
        {
            return(assetBundleData.baseElement);
        }
        return(null);
    }