Beispiel #1
0
        protected bool CreateAssetBundleAsync(string assetbundleName, bool isIndependent = false)
        {
            #if UNITY_EDITOR
//            EditorApplication.isPaused = true;
            #endif


            if (IsAssetBundleLoaded(assetbundleName) || webRequesting.ContainsKey(assetbundleName))
            {
                return(false);
            }

            var creater = ResourceWebRequester.Get();
            var url     = AssetBundleUtility.GetAssetBundleFileUrl(assetbundleName);
            if (!manifest.GetAssetBundleHash(assetbundleName).isValid&& idpManifest.GetAssetBundleHash(assetbundleName).isValid)
            {
                url = AssetBundleUtility.GetIndependentAssetBundleFileUrl(assetbundleName);
            }
            creater.Init(assetbundleName, url);
            webRequesting.Add(assetbundleName, creater);
            webRequesterQueue.Enqueue(creater);
            // 创建器持有的引用:创建器对每个ab来说是全局唯一的
            IncreaseReferenceCount(assetbundleName);
            return(true);
        }
Beispiel #2
0
        // 从服务器下载网页内容,需提供完整url,非AB(不计引用计数、不缓存),Creater使用后记得回收
        public ResourceWebRequester DownloadWebResourceAsync(string url)
        {
            var creater = ResourceWebRequester.Get();

            creater.Init(url, url, new DownloadHandlerBuffer(), true);
            webRequesterQueue.Enqueue(creater);
            return(creater);
        }
 // 从服务器下载网页内容,需提供完整url,非AB(不计引用计数、不缓存),Creater使用后记得回收
 public ResourceWebRequester DownloadWebResourceAsync(string url)
 {
     var creater = ResourceWebRequester.Get();
     creater.Init(url, url, true);
     webRequesting.Add(url, creater);
     webRequesterQueue.Enqueue(creater);
     return creater;
 }
 // 本地异步请求Assetbundle资源,不计引用计数、不缓存,Creater使用后记得回收
 public ResourceWebRequester RequestAssetBundleAsync(string assetbundleName)
 {
     var creater = ResourceWebRequester.Get();
     var url = AssetBundleUtility.GetAssetBundleFileUrl(assetbundleName);
     creater.Init(assetbundleName, url, true);
     webRequesting.Add(assetbundleName, creater);
     webRequesterQueue.Enqueue(creater);
     return creater;
 }
        // 从资源服务器下载Assetbundle资源,非AB(不计引用计数、不缓存),Creater使用后记得回收
        public ResourceWebRequester DownloadAssetBundleAsync(string filePath)
        {
            var creater = ResourceWebRequester.Get();
            var url     = DownloadUrl + filePath;

            creater.Init(filePath, url, new DownloadHandlerAssetBundle(url, 0), true);
            webRequesterQueue.Enqueue(creater);
            return(creater);
        }
        // 异步请求非Assetbundle资源,不缓存,无依赖
        public ResourceWebRequester RequestFileAssetAsync(string filePath)
        {
            var creater = ResourceWebRequester.Get();
            var url     = AssetBundleUtility.GetPlatformFileUrl(filePath);

            creater.Init(filePath, url, true);
            webRequesting.Add(filePath, creater);
            webRequesterQueue.Enqueue(creater);
            return(creater);
        }
        // 本地异步请求Assetbundle资源,不计引用计数、不缓存,Creater使用后记得回收
        public ResourceWebRequester RequestAssetBundleAsync(string assetbundleName)
        {
            var creater = ResourceWebRequester.Get();
            var url     = AssetBundleUtility.GetAssetBundleFileUrl(assetbundleName);

#if UNITY_CLIENT
            Debug.Log("RequestAssetBundleAsync:" + url);
#endif
            creater.Init(assetbundleName, url, true);
            webRequesting.Add(assetbundleName, creater);
            webRequesterQueue.Enqueue(creater);
            return(creater);
        }
        // 从资源服务器下载非Assetbundle资源,非AB(不计引用计数、不缓存),Creater使用后记得回收
        public ResourceWebRequester DownloadAssetFileAsync(string filePath)
        {
            if (string.IsNullOrEmpty(DownloadUrl))
            {
                Logger.LogError("You should set download url first!!!");
                return null;
            }

            var creater = ResourceWebRequester.Get();
            var url = DownloadUrl + filePath;
            creater.Init(filePath, url, true);
            webRequesting.Add(filePath, creater);
            webRequesterQueue.Enqueue(creater);
            return creater;
        }
        protected bool CreateAssetBundleAsync(string assetbundleName)
        {
            if (IsAssetBundleLoaded(assetbundleName) || webRequesting.ContainsKey(assetbundleName))
            {
                return false;
            }

            var creater = ResourceWebRequester.Get();
            var url = AssetBundleUtility.GetAssetBundleFileUrl(assetbundleName);
            creater.Init(assetbundleName, url);
            webRequesting.Add(assetbundleName, creater);
            webRequesterQueue.Enqueue(creater);
            // 创建器持有的引用:创建器对每个ab来说是全局唯一的
            IncreaseReferenceCount(assetbundleName);
            return true;
        }
Beispiel #10
0
        // 从资源服务器下载非Assetbundle资源,非AB(不计引用计数、不缓存),Creater使用后记得回收
        public ResourceWebRequester DownloadAssetFileAsync(string filePath)
        {
            if (string.IsNullOrEmpty(DownloadUrl))
            {
                Logger.LogError("You should set download url first!!!");
                return(null);
            }

            var creater = ResourceWebRequester.Get();
            var url     = DownloadUrl + filePath;

            //var saveUrl = AssetBundleUtility.GetPersistentFilePathWWW(filePath);
            creater.Init(filePath, url, new DownloadHandlerBuffer(), true);
            webRequesterQueue.Enqueue(creater);
            return(creater);
        }
 // 本地异步请求非Assetbundle资源,非AB(不计引用计数、不缓存),Creater使用后记得回收
 public ResourceWebRequester RequestAssetFileAsync(string filePath, bool streamingAssetsOnly = true)
 {
     var creater = ResourceWebRequester.Get();
     string url = null;
     if (streamingAssetsOnly)
     {
         url = AssetBundleUtility.GetStreamingAssetsFilePath(filePath);
     }
     else
     {
         url = AssetBundleUtility.GetAssetBundleFileUrl(filePath);
     }
     creater.Init(filePath, url, true);
     webRequesting.Add(filePath, creater);
     webRequesterQueue.Enqueue(creater);
     return creater;
 }
        // 本地异步请求非Assetbundle资源,非AB(不计引用计数、不缓存),Creater使用后记得回收
        public ResourceWebRequester RequestAssetFileAsync(string filePath, bool streamingAssetsOnly = true)
        {
            var    creater = ResourceWebRequester.Get();
            string url     = null;

            if (streamingAssetsOnly)
            {
                url = AssetBundleUtility.GetStreamingAssetsFilePathWWW(filePath);
            }
            else
            {
                url = AssetBundleUtility.GetAssetFileUrlWWW(filePath);
            }
            creater.Init(filePath, url, new DownloadHandlerBuffer(), true);
            webRequesterQueue.Enqueue(creater);
            return(creater);
        }
        // 从资源服务器下载非Assetbundle资源,非AB(不计引用计数、不缓存),Creater使用后记得回收
        public ResourceWebRequester DownloadAssetFileAsync(string filePath, bool isLoadBundle = false)
        {
            if (string.IsNullOrEmpty(DownloadUrl))
            {
                Logger.LogError("You should set download url first!!!");
                return(null);
            }

            var creater = ResourceWebRequester.Get();
            var url     = DownloadUrl + filePath;

            Debug.Log("DownloadAssetFileAsync >>url  " + url);
            creater.Init(filePath, url, true, isLoadBundle);
            webRequesting.Add(filePath, creater);
            webRequesterQueue.Enqueue(creater);
            return(creater);
        }
        // 从资源服务器下载非Assetbundle资源,非AB(不计引用计数、不缓存),Creater使用后记得回收
        public ResourceWebRequester DownloadAssetFileAsync(string filePath)
        {
            if (string.IsNullOrEmpty(DownloadUrl))
            {
                Logger.LogError("You should set download url first!!!");
                return(null);
            }

            var creater = ResourceWebRequester.Get();
            var url     = DownloadUrl + filePath;

            #if UNITY_CLIENT
            Debug.Log("DownloadAssetFileAsync:" + url);
            #endif
            creater.Init(filePath, url, true);
            webRequesterQueue.Enqueue(creater);
            return(creater);
        }