Hi i a very new to unity, I have a problem with instantiate in web build.
I cannot load an object in web player. When i try to load it in editor it loads perfectly.
This is the code that i use
if (Application.isEditor) {
assetPath = “file:///” + Application.streamingAssetsPath + “/” + thumb + goniakos + “" + width + length + “.unity3d”;
var eee = Application.streamingAssetsPath + “/” + thumb + goniakos + "” + width + length + “.unity3d”;
}
else {
message += " isNotEditor";
assetPath = Application.dataPath + "/StreamingAssets" + "/" + thumb + goniakos + "_" + width + length + ".unity3d";
eee = Application.dataPath + "/StreamingAssets" + "/" + thumb + goniakos + "_" + width + length + ".unity3d";
}
message += assetPath;
var www = new WWW(assetPath);
var instance : GameObject = Instantiate(www.assetBundle.mainAsset);
message += " isNotEditor";
thumb, width, and length are variables
When i print the variable assetPath its a valid http address but the object doesent load
Thank you
> I tried that but the above code is inside a OnGUI function and the yield throws an error, that says OnGUI() cannot be a coroutine Then instead of "yield www", check www.isDone. When www.isDone is true, this means the download is done and you can instantiate objects.
– TonyLican i use www.isDone with javascript?
– pitzav_gmail.comYes. Just keep checking each OnGUI() until www.isDone returns true. Refer to: http://docs.unity3d.com/Documentation/ScriptReference/WWW.html
– TonyLiif((www.isDone == true)){ this doesent work what am i doing wrong?
– pitzav_gmail.comWhat error does it report? Consider moving your code out of OnGUI() and using yield. For example, the sample code is in Start(). (See the WWW.html link in my previous comment for the sample code.)
– TonyLi