Ejemplo n.º 1
0
        /// <summary>
        /// 加载UI资源
        /// </summary>
        /// <param name="assetPath"></param>
        /// <param name="onComplete"></param>
        private void LoadUIAsset(string assetPath, BaseAction <ResourceEntity> onComplete)
        {
#if DISABLE_ASSETBUNDLE && UNITY_EDITOR
            string path = string.Format("Assets/Download/UI/UIPrefab/{0}.prefab", assetPath);
            //加载镜像
            Object obj = UnityEditor.AssetDatabase.LoadAssetAtPath <GameObject>(path);
            if (onComplete != null)
            {
                AssetEntity    m_CurrAssetEntity    = GameEntry.Resource.ResourceLoaderManager.GetAssetEntity(AssetCategory.UIPrefab, string.Format("Assets/Download/UI/UIPrefab/{0}.prefab", assetPath));
                ResourceEntity m_CurrResourceEntity = GameEntry.Pool.DequeueClassObject <ResourceEntity>();
                m_CurrResourceEntity.Category      = m_CurrAssetEntity.Category;
                m_CurrResourceEntity.IsAssetBundle = false;
                m_CurrResourceEntity.ResourceName  = m_CurrAssetEntity.AssetFullName;
                m_CurrResourceEntity.Target        = obj;
                GameEntry.Pool.PoolManager.AssetPool[m_CurrAssetEntity.Category].Register(m_CurrResourceEntity);

                onComplete(m_CurrResourceEntity);
            }
#else
            GameEntry.Resource.ResourceLoaderManager.LoadMainAsset(AssetCategory.UIPrefab, string.Format("Assets/Download/UI/UIPrefab/{0}.prefab", assetPath), (ResourceEntity entity) =>
            {
                if (onComplete != null)
                {
                    onComplete(entity);
                }
            });
#endif
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 初始化资源信息,赋值字典
        /// </summary>
        /// <param name="buffer"></param>
        private void InitAssetInfo(byte[] buffer)
        {
            buffer = ZlibHelper.DeCompressBytes(buffer);

            MMO_MemoryStream ms = new MMO_MemoryStream(buffer);
            int len             = ms.ReadInt();
            int depLen          = 0;

            for (int i = 0; i < len; i++)
            {
                AssetEntity entity = new AssetEntity();
                entity.Category        = (AssetCategory)ms.ReadByte();
                entity.AssetFullName   = ms.ReadUTF8String();
                entity.AssetBundleName = ms.ReadUTF8String();
                depLen = ms.ReadInt();
                if (depLen > 0)
                {
                    entity.DependsAssetList = new List <AssetDependsEntity>();
                    for (int j = 0; j < depLen; j++)
                    {
                        AssetDependsEntity dep = new AssetDependsEntity();
                        dep.Category      = (AssetCategory)ms.ReadByte();
                        dep.AssetFullName = ms.ReadUTF8String();
                        entity.DependsAssetList.Add(dep);
                    }
                }

                m_AssetInfoDic[entity.Category][entity.AssetFullName] = entity;
            }
        }
 /// <summary>
 /// 重置
 /// </summary>
 private void Reset()
 {
     m_OnComplete               = null;
     m_CurrAssetEntity          = null;
     m_CurrResourceEntity       = null;
     m_NeedLoadAssetDependCount = 0;
     m_CurrLoadAssetDependCount = 0;
     m_DependsResourceList.Clear();
     GameEntry.Pool.EnqueueClassObject(this);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 根据资源分类和资源路径获取资源信息
        /// </summary>
        /// <param name="assetCategory"></param>
        /// <param name="assetFullName"></param>
        /// <returns></returns>
        public AssetEntity GetAssetEntity(AssetCategory assetCategory, string assetFullName)
        {
            Dictionary <string, AssetEntity> dicCategory = null;

            if (m_AssetInfoDic.TryGetValue(assetCategory, out dicCategory))
            {
                AssetEntity entity = null;
                if (dicCategory.TryGetValue(assetFullName, out entity))
                {
                    return(entity);
                }
            }
            GameEntry.LogError("assetFullName=>{0}不存在", assetFullName);
            return(null);
        }
 /// <summary>
 /// 加载主资源
 /// </summary>
 /// <param name="assetCategory"></param>
 /// <param name="assetFullName"></param>
 /// <param name="onComplete"></param>
 public void Load(AssetCategory assetCategory, string assetFullName, BaseAction <ResourceEntity> onComplete = null)
 {
     m_OnComplete      = onComplete;
     m_CurrAssetEntity = GameEntry.Resource.ResourceLoaderManager.GetAssetEntity(assetCategory, assetFullName);
     LoadDependsAsset();
 }