Beispiel #1
0
        /// <summary>
        /// 单个 AB加载完成的回调
        /// 保存AB到BundleNode
        /// </summary>
        /// <param name="operation"></param>
        protected override void OnAsyncOperationLoaded(AAssetAsyncOperation operation)
        {
            BundleNode bundleNode = m_BundleNodeDic[operation.AssetPath];

            bundleNode.SetAssetBundle((operation.GetAsset() as AssetBundle));

            m_LoadingAsyncOperationDic.Remove(operation.AssetPath);
        }
 /// <summary>
 /// 元素回收时被调用
 /// </summary>
 public void OnRelease()
 {
     m_AssetPath = null;
     m_BundleNode.ReleaseRefCount();
     m_BundleNode = null;
     m_WeakAssets.Clear();
     m_LoadCount = 0;
 }
Beispiel #3
0
        /// <summary>
        /// 内部卸载无用资源函数
        /// 根据资源的记数查找可以释放的资源
        /// </summary>
        protected override void InnerUnloadUnusedAssets()
        {
            string[] assetNodeKeys = (from nodeKVP in m_AssetNodeDic where !nodeKVP.Value.IsAlive() select nodeKVP.Key).ToArray();
            foreach (var key in assetNodeKeys)
            {
                AssetNode assetNode = m_AssetNodeDic[key];
                m_AssetNodeDic.Remove(key);
                m_AssetNodePool.Release(assetNode);
            }

            string[] bundleNodeKeys = (from nodeKVP in m_BundleNodeDic where nodeKVP.Value.RefCount == 0 select nodeKVP.Key).ToArray();
            foreach (var key in bundleNodeKeys)
            {
                BundleNode bundleNode = m_BundleNodeDic[key];
                m_BundleNodeDic.Remove(key);
                m_BundleNodePool.Release(bundleNode);
            }
        }
 /// <summary>
 /// 初始化
 /// </summary>
 /// <param name="path">资源路径</param>
 /// <param name="node">主BundleNode</param>
 public void InitNode(string path, BundleNode node)
 {
     m_AssetPath  = path;
     m_BundleNode = node;
     m_BundleNode.RetainRefCount();   //BundleNode 引用数量+1
 }
 /// <summary>
 /// 保存它的依赖 BundleNode
 /// </summary>
 /// <param name="node"></param>
 public void AddDependNode(BundleNode node)
 {
     m_DirectDependNodes.Add(node);
     node.RetainRefCount();
 }