Ejemplo n.º 1
0
        /// <summary>
        /// 获取已加载的资源
        /// </summary>
        public GameObject GetPrefab(ResType type, string abName)
        {
            GameObject      obj         = null;
            string          abPath      = ResConfig.GetABPath(type, abName);
            AssetBundleData assetBundle = GetAssetBundle(abPath);

            if (assetBundle == null)
            {
                LoadAssetBundle(abPath);
                LogUtil.LogError("资源获取失败------abName:" + abPath);
                return(null);
            }
            else
            {
                dicAssetBundle.TryGetValue(abPath, out assetBundle);
                if (assetBundle != null)
                {
                    obj = assetBundle.ab.LoadAsset(abName, typeof(GameObject)) as GameObject;
                }
            }

            if (obj == null)
            {
                LogUtil.LogError("资源获取失败------abName:" + abName);
                return(null);
            }
            return(UnityEngine.Object.Instantiate <GameObject>(obj));
        }
Ejemplo n.º 2
0
        public void UnLoadAssetBundle(ResType type, string abName)
        {
            //这里可以过滤一下公共资源

            //卸载资源
            string abPath = ResConfig.GetABPath(type, abName);

            UnloadAssetBundleInternal(abPath);
            UnloadDependencies(abPath);
        }
Ejemplo n.º 3
0
 private void LoadConfig()
 {
     AssetManager.Instance.LoadConfig(ResType.Config, ResConfig.GetABPath(ResType.Config, ""), "", LoadComplete);
 }