using UnityEngine;

namespace XGame.Framework.Asset
{
    /// <summary>
    /// AssetBundle资源
    /// </summary>
    internal class BundleAsset : Asset
    {
        private AssetBundle assetBundle;

        #region 重载
        public override AssetType AssetType => AssetType.AssetBundle;
        public override object Clone()
        {
            if (assetBundle != null)
            {
                Retain();
            }
            return assetBundle;
        }
        protected override void OnDispose()
        {
            if (assetBundle != null)
            {
                assetBundle.Unload(true);
                assetBundle = null;
            }

        }
        protected override void OnInit()
        {

        }

        protected override void OnRelease()
        {

        }

        protected override void OnRetain()
        {

        }

        protected override void OnSetSource()
        {
            if (Source != null)
            {
                assetBundle = (AssetBundle)Source;
            }
            else
            {
                assetBundle = null;
            }
        }


        #endregion
    }
}

