Exemple #1
0
 public void Init(ResData data)
 {
     m_assetName = data.assetName;
     m_state     = ResState.Waiting;
     m_type      = ResType.Resource;
     m_asset     = null;
 }
Exemple #2
0
        /// <summary>
        /// 获取Res对象
        /// </summary>
        /// <param name="data"></param>
        /// <param name="create"></param>
        public Res _Get(ResData data, bool create = false)
        {
            Res res = null;

            if (poolDic.TryGetValue(data.poolKey, out res))
            {
                res.Retain();
                return(res);
            }

            if (!create)
            {
                return(null);
            }

            res = ResFactory.Create(data);

            if (res == null)
            {
                return(null);
            }

            res.Retain();

            poolDic.Add(data.poolKey, res);
            if (!poolList.Contains(res))
            {
                poolList.Add(res);
            }

            return(res);
        }
Exemple #3
0
        public static ResourceRes Allocate(ResData data)
        {
            var res = SafeObjectPool <ResourceRes> .Instance.Allocate();

            res.Init(data);
            return(res);
        }
Exemple #4
0
 public void Init(ResData data)
 {
     m_bundleName  = data.bundleName;
     m_state       = ResState.Waiting;
     m_type        = ResType.Bundle;
     m_asset       = null;
     m_assetBundle = null;
 }
Exemple #5
0
 /// <summary>
 /// 搜索bundle
 /// </summary>
 private bool SearchAssetBundle()
 {
     if (m_assetBundle == null)
     {
         m_bundleRes = ResPoolSystem.Get <BundleRes>(ResData.AllocateBundle(bundleName));
         if (m_bundleRes != null)
         {
             m_assetBundle = m_bundleRes.assetBundle;
         }
     }
     return(m_assetBundle != null);
 }
Exemple #6
0
        /// <summary>
        /// 查找依赖
        /// </summary>
        private bool FindDependencies()
        {
            string[] ds     = AssetBundleDependencies.GetDependencies(m_bundleName);
            int      length = ds.Length;

            m_dependencies = new BundleRes[length];
            for (int i = 0; i < length; i++)
            {
                m_dependencies[i] = ResPoolSystem.Get <BundleRes>(ResData.AllocateBundle(ds[i]), true);
            }
            return(length > 0);
        }
        public void Init(string bundleName, string assetName, ResNotificationListener listener)
        {
            m_only = string.IsNullOrEmpty(assetName);

            m_bundleRes = ResPoolSystem.Get <BundleRes>(ResData.AllocateBundle(bundleName), true);

            if (!m_only)
            {
                m_assetRes = ResPoolSystem.Get <AssetRes>(ResData.AllocateAsset(assetName, bundleName), true);
            }

            m_listener = listener;
        }
Exemple #8
0
 /// <summary>
 /// 获取资源
 /// </summary>
 /// <param name="data"></param>
 /// <param name="createNew">如果没有是否创建</param>
 public static Res Get(ResData data, bool createNew = false)
 {
     return(Instance._Get(data, createNew));
 }
Exemple #9
0
 /// <summary>
 /// 获取资源
 /// </summary>
 /// <param name="data"></param>
 /// <param name="createNew">如果没有是否创建</param>
 public static T Get <T>(ResData data, bool createNew = false) where T : Res
 {
     return(Get(data, createNew) as T);
 }