- Home /
Question by
santafeast · Oct 26, 2018 at 12:22 PM ·
webglassetbundle
How to download Assetbundles and put them into a particular folder in WEBGL
Actually i am trying to make asset bundles of my sprites and load them into the server. i have successfully created the asset bundles for WEBGL platform now i want it to be loaded on runtime and to be saved in a particular folder eg., Resources or Streaming Assets. so that i can load a particular sprite just by calling its path
static void BuildAllAssetBundles()
{
string assetBundleDirectory = "Assets/AssetBundles";
if (!Directory.Exists(assetBundleDirectory))
{
Directory.CreateDirectory(assetBundleDirectory);
}
BuildPipeline.BuildAssetBundles(assetBundleDirectory, BuildAssetBundleOptions.None, BuildTarget.WebGL);
}
this is the code which i used to generate asset bundles
void Start () { StartCoroutine ("LoadAssets"); }
IEnumerator LoadAssets()
{
string uri = Path.Combine(Application.dataPath, "/AssetBundles/" + "model");
UnityWebRequest request = UnityWebRequestAssetBundle.GetAssetBundle(uri, 0);
yield return request.SendWebRequest();
AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(request);
}
}
this is the code which i am using to save these assets into AssetBundles folder... but i am unsuccessfull please give me some correct method for doing this
Comment