- Home /
Dynamic object Instantiate
Hi everyone !
Despite my searches around the Web I can’t find anything about how to solve a problem i encounter with Unity so I’m posting here, hoping some of you guys will be able to help me.
My problem is when I use either local data or online data in unity everything works just fine but when I try to export to the web player everything collapses.
OK so this is what I do, maybe that will help:
I store a series of objects in a list (List) coming from a loading of asset Bundle i made myself and it seems that’s where the issues comes from. The objects stored in that list are dynamics, they are stored as asset Bundles and not prefabs.
It works pretty well in Unity when I use it in local (local database, resources etc) but when I export to the web player, the instances of the objects are bugged and the player crashes!
the code I use:
GameObject TempObjAdd = (GameObject) Instantiate(datasM.Addobjet, cible.transform.position, Quaternion.identity) as GameObject;
« datasM.Addobjet » is the object from the list I use.
After several tests, it seems to be rights there at that point of the code but it’s instantiation doesn’t seem to work.
An instance like this one that seems to work just fine in Unity.
public GameObject ball;
GameObject TempObjAdd = (GameObject) Instantiate(ball, cible.transform.position, Quaternion.identity) as GameObject;
Did some of you guys ever encounter the same problem?
Thanks for helping!
Answer by Graham-Dunnett · May 27, 2011 at 09:54 AM
Hard to make any suggestions based on this information. Probably assume that the asset bundle does not contain the object you are loading, so perhaps use:
http://unity3d.com/support/documentation/ScriptReference/AssetBundle.Contains.html
If you need more help, maybe post the script you use to create the asset bundle, and the code you use to load the asset bundle and load the objects from it.
Asset Bundles are a Pro feature.
Hey, thx for your answer. The thing is that in Unity everything works fine. Assets are loaded and checked before they're instancied so my guess is that it doesn't come from that. I don't get any errors with the code either local or web as long as i'm IN UNITY. The problem really is the export to the webplayer. Note that i load the assetbundle in a list and i don't use them after that in the aplication, only in the item list.
The version i use is 3,0, pro and i use assetbundle on an other part and it works as well online and offline.
Do you know about a way to instanciate an object in the webplayer ? Does it come from the code or from the player itself ?
Your answer
Follow this Question
Related Questions
Create an AssetBundle with prefabs containing imported models 0 Answers
Wait for coroutine to finish before returning a value in another function 0 Answers
Unity 3D Keep Crashing in every site! 1 Answer
Changing game object based on variable state? 1 Answer
Assign www.assetBundle to new AssetBundle Freezes WebPlayer 0 Answers