コード例 #1
0
        //移除BundleInfo
        public bool RemoveAssetBundleInfo(string assetBundleName, string assetBundleVariant)
        {
            AssetInfo[] assetsToRemove = m_AssetBundleCollection.GetAssetInfos(assetBundleName, assetBundleVariant);    //获取BundleInfo关联的所有资源信息
            if (m_AssetBundleCollection.RemoveAssetBundle(assetBundleName, assetBundleVariant))
            {
                List <SourceAsset> unassignedSourceAssets = new List <SourceAsset>(); //取消分配的资源列表
                foreach (AssetInfo asset in assetsToRemove)
                {
                    SourceAsset sourceAsset = GetSourceAsset(asset.Guid);
                    if (sourceAsset != null)
                    {
                        unassignedSourceAssets.Add(sourceAsset);
                    }
                }

                if (EventOnAssetUnassigned != null)
                {
                    EventOnAssetUnassigned.Invoke(unassignedSourceAssets.ToArray());
                }

                return(true);
            }

            return(false);
        }
コード例 #2
0
        //取消分配资源
        public bool UnassignAssetInfo(string assetGuid)
        {
            if (m_AssetBundleCollection.UnassignAssetInfo(assetGuid))
            {
                SourceAsset sourceAsset = GetSourceAsset(assetGuid);
                if (sourceAsset != null)
                {
                    if (EventOnAssetUnassigned != null)
                    {
                        EventOnAssetUnassigned.Invoke(new SourceAsset[] { sourceAsset });
                    }
                }

                return(true);
            }

            return(false);
        }