Exemplo n.º 1
0
        /// <summary>
        /// 卸载资源
        /// </summary>
        /// <param name="asset"></param>
        public void UnloadAssetAsync(UnityEngine.Object asset)
        {
            MDebug.Assert(asset != null, LOG_TAG, "asset != null");
            MDebug.Assert(m_AssetToAssetHandlerMap.ContainsKey(asset), LOG_TAG, "m_AssetToAssetHandlerMap.ContainsKey(asset)");

            if (asset == null || !m_AssetToAssetHandlerMap.ContainsKey(asset))
            {
                return;
            }
            AssetHandler assetHandler = m_AssetToAssetHandlerMap[asset];

            if (assetHandler == null)
            {
                MDebug.Log(LOG_TAG, $"UnloadAssetAsync({assetHandler.GetAssetKey()})");

                AssetAction assetAction = assetHandler.RemoveReference();
                switch (assetAction)
                {
                case AssetAction.Unload:
                    AddAssetActionRequest(assetHandler.GetAssetIndex(), AssetAction.Unload);
                    break;

                default:
                    MDebug.Log(LOG_TAG, "unload failed !");
                    break;
                }
            }
        }