Exemple #1
0
        /// <summary>
        /// 从Assetbundle中异步加载一个资源,自动处理依赖关系
        /// </summary>
        /// <typeparam name="T">UnityAsset类型</typeparam>
        /// <param name="_assetbundle_name">目标Assetbundle名称</param>
        /// <param name="_asset_name">Asset名称</param>
        /// <param name="_callback">回调</param>
        public void LoadAssetAsync <T>(String _assetbundle_name, String _asset_name, Predicate <Boolean, Resource_Assetbundle, UnityEngine.Object> _callback) where T : UnityEngine.Object
        {
            Resource_Base res_assetbundle = GetResource(_assetbundle_name) as Resource_Assetbundle;

            if (res_assetbundle == null)
            {
                _callback(false, null, null);
                Log.Error("[ResouceManager.LoadAssetAsync<T>]: res [{0}] 不存在!或类型不为Assetbundle", _assetbundle_name);
                return;
            }

#if UNITY_EDITOR
            // 其实没有意义的验证, 除非Resource_assetbundle和内部存储的类型不同
            if (res_assetbundle.ResouceInfo.ResType != ResourceType.AssetBundle)
            {
                _callback(false, null, null);
                Log.Error("[AssetManager]: 请求加载的Assetbundle: {0} Asset: {1} 为非Assetbundle资源! 类型为: {2}", _assetbundle_name, _asset_name, res_assetbundle.ResouceInfo.ResType);
                return;
            }
#endif

            var task = new UnityAssetLoadTask(res_assetbundle as Resource_Assetbundle, _asset_name, typeof(T), _callback);

            m_running_task.AddLast(task);
        }
Exemple #2
0
 public void _addToLoadedResourceList(Resource_Base _asset)
 {
     if (m_loaded_assets.Contains(_asset))
     {
         return;
     }
     m_loaded_assets.AddLast(_asset);
 }
Exemple #3
0
 public void _addToPendingUnloadResourceList(Resource_Base _resource)
 {
     if (m_pending_delete_list.Contains(_resource))
     {
         return;
     }
     m_pending_delete_list.AddLast(_resource);
 }
Exemple #4
0
        public void LoadSceneAsync(String _assetbundle_name, String _scene_name, Action <Boolean> _callback)
        {
            //_scene_name = _scene_name.ToLower();
#if GROOT_ASSETBUNDLE_SIMULATION || !UNITY_EDITOR
            StartCoroutine(_loadSceneAsync(_scene_name, _callback));
#else
            Resource_Base resource_assetbundle = GetResource(_assetbundle_name);
            if (resource_assetbundle == null)
            {
                _callback(false);
                return;
            }
            var task = new UnitySceneLoadTask(resource_assetbundle as Resource_Assetbundle, _scene_name, _callback);
            m_running_task.AddLast(task);
#endif
        }