playMaker

Author Topic: AssetBundle loading from WWW  (Read 4748 times)

dblincoeii

  • Playmaker Newbie
  • *
  • Posts: 14
AssetBundle loading from WWW
« on: December 17, 2015, 06:46:31 PM »
I have been trying to figure this out for sometime now. Loading AssetBundles seems like such a touted useful tool but very little in regards to solid tutorials.  I've downloaded the playmaker www asset bundle package and have it installed but can't seem to figure out how to plug it up in my FSM.  For instance I have an asset bundle loaded to an ftp site but how do download it?  I can't seem to plug anything in the "Store Bundle" dropdown...it always says "none"

Anybody out there that could shed some light on this process, point me to a tutorial or even create a mini-tut I would be very grateful.

Thanks in advance for your help!
Dan

dejaime

  • Playmaker Newbie
  • *
  • Posts: 5
Re: AssetBundle loading from WWW
« Reply #1 on: January 07, 2016, 09:07:09 AM »
Hi,

I would recommend the following pages:
For the WWW part - http://docs.unity3d.com/ScriptReference/WWW.html
For the AssetBundle part - http://docs.unity3d.com/ScriptReference/AssetBundleRequest.html

In theory, you should do something like this (not at all tested) code:

Code: [Select]
/// <summary>
/// Tries downloading the bundle
/// </summary>
IEnumerator tryDownload() {

Debug.Log("Starting tryDownload coroutine. Url:[" + url + "]");

using (WWW www = new WWW(url)) {
//wait for the www
yield return www;

//WWW done, let's load the bundle or pass the error.
if (www.error != null) {
//Do your error handling
} else {
//Check if the downloaded data contains an assetBundle
if(www.assetBundle == null){
Debug.Log("www.assetBundle is null.");
}

//Load the asset from the bundle
AssetBundleRequest assetRequest = www.assetBundle.LoadAssetAsync("resource", typeof(GameObject));
yield return assetRequest;


GameObject gObj = (GameObject)www.assetBundle.mainAsset;

if (gObj == null) {
//Do your error handling
} else {
//Do whatever you need with the gObj game object
}
}
}

Debug.Log("Finishing tryDownload coroutine.");

}

memetic arts

  • Full Member
  • ***
  • Posts: 141
Re: AssetBundle loading from WWW
« Reply #2 on: January 12, 2016, 03:00:31 AM »
The variable needs to be of type "object", and for Object Type, you must first pick "Unity Engine", and then, in the subsequent fly-out menu, select "AssetBundle". 

You'll then see the variable as an option for assignment.


memetic arts

  • Full Member
  • ***
  • Posts: 141
Re: AssetBundle loading from WWW
« Reply #3 on: January 13, 2016, 07:00:50 PM »
I know, responding to my own response again, bad habit.  :-)

But I think I'm in the same boat as dblincoeii, even after properly assigning the variable. 

If the action's only purpose to store the AssetBundle, how would you go about actually using it, e.g. extracting the assets, etc.?

I know that Jean said he's working on an update for 1.8 . . . will those actions be included, or am I missing something?

Thanks!

memetic arts

  • Full Member
  • ***
  • Posts: 141
Re: AssetBundle loading from WWW
« Reply #4 on: January 15, 2016, 12:14:46 PM »
Sorry, wanted to bump this before it scrolls off the page . . . any clarification as to the expected usage of this action, or insight as to when a more complete set of AssetBundle management actions might be available, would be greatly appreciated.

Thanks!

dblincoeii

  • Playmaker Newbie
  • *
  • Posts: 14
Re: AssetBundle loading from WWW
« Reply #5 on: April 01, 2016, 01:26:11 PM »
Sorry for asking a question and being silent for awhile. My wife had a baby and has been extremely sick and had two surgeries since. 

I'm still in the same boat and either not understanding or missing some actions all together.  I think I understand that you load an asset bundle with WWW and store it in an object.  But how do you tell it to display the contents?  For instance, if there are two cubes (one red and one blue) how do you extract and display the blue cube from the downloaded asset bundle???

Thanks again for the help...I'll try to stick around! :D