using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Giant.Res {

    public class BundleAssetRequest : AssetRequest
    {

        protected readonly string assetBundleName;
        protected BundleRequest bundle;

        public BundleAssetRequest(string bundle)
        {
            assetBundleName = bundle;
        }

        internal override void Load()
        {
            bundle = AssetsMgr.LoadBundle(assetBundleName);
            var assetName = path;// Path.GetFileName(path);
            asset = bundle.assetBundle.LoadAsset(assetName, assetType);
        }

        internal override void Unload()
        {
            if (bundle != null)
            {
                bundle.Release();
                bundle = null;
            }
            asset = null;
        }
    }
}