1、首先我们需要把资源打包成asset,我们需要先创建一个AssetBundleConfig文件,使用该文件来配置我们打包单个资源和打包文件夹资源的路径以及AB名。 usingSystem.Collections;usingSystem.Collections.Generic;usingUnityEngine;[CreateAssetMenu(fileName = "ABconfig",menuName = "Create ABConfig",order = 0)]publicclass...
若AssetBundles采用LZMA压缩方式,则会对AssetBundles解压;若采用LZ4压缩,则会以压缩态加载。 IEnumeratorStart(){varuwr=UnityWebRequest.Get("https://myserver/myBundle.unity3d");yieldreturnuwr.SendWebRequest();byte[]decryptedBytes=MyDecription(uwr.downloadHandler.data);AssetBundle.LoadFromMemory(decryptedBy...
usingUnityEngine;usingSystem.Collections;usingUnityEngine.Networking;publicclassLoadFromFileExample:MonoBehaviour{IEnumeratorStart(){//第三种加载方式 使用UnityWbRequest 服务器加载使用http本地加载使用file//string uri = @"file:///C:\Users\Administrator\Desktop\AssetBundleProject\AssetBundles\model.ab";stringu...
AssetBundle.LoadAll (type : Type) : Object[] 加载所有包含在asset bundle中且继承自type的对象; AssetBundle.LoadAll () : Object[] 加载所有包含在asset bundle中的对象; AssetBundle.mainAsset 主资源在构建资源boundle时指定(只读),该功能可以方便的找到bundle内的主资源。例如,你也许想有一个角色的预制体并...
IEnumerator InstantiateObject() { string url = "file:///" + Application.dataPath + "/AssetBundles/" + assetBundleName; var request = UnityEngine.Networking.UnityWebRequestAssetBundle.GetAssetBundle(url, 0); yield return request.Send(); AssetBundle bundle = UnityEngine.Networking.DownloadHandlerAssetB...
UnityEngine.Networking.UnityWebRequest.GetAssetBundle(uri, 0); yield return request.Send(); AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(request); GameObject cube = bundle.LoadAsset<GameObject>("Cube"); GameObject sprite = bundle.LoadAsset<GameObject>("Sprite"); Instantiate(cube); ...
过去会使用WWW作为加载方式,现在基本使用UnityWebRequest, UnityWebRequest request = UnityWebRequestAssetBundle.GetAssetBundle(path); 这里的path是 Path.Combine(Application.streamingAssetsPath,bundleName) 出来的,bundleName是打出来的ab包的名字,要加后缀名...
IEnumeratorInstantiateObject(){stringuri="file:///"+Application.dataPath+"/AssetBundles/"+assetBundleName;UnityEngine.Networking.UnityWebRequestrequest=UnityEngine.Networking.UnityWebRequest.GetAssetBundle(uri,0);yieldreturnrequest.Send();AssetBundlebundle=DownloadHandlerAssetBundle.GetContent(request);GameObject...
UnityWebRequest request = UnityWebRequestAssetBundle.GetAssetBundle(url); //等待文件下载完毕 yield return request.SendWebRequest(); AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(request); //加载AssetBundle资源 AssetBundleRequest ABrequest = bundle.LoadAssetAsync("Cube.prefab", typeof(GameObject...
I have a Unity WebGL project that tries to load AssetBundles, but I get an error: Unable to open archive file: http://localhost:50212/StreamingAssets/Bundles/language_english The code that creates the AssetBundles: using UnityEditor; using System.IO; using UnityEngine; public class JC_Bundler...