- Home /
how to add models dynamically at runtime in unity web output?
I am new to unity. I want to know how to add models to my building from a folder at runtime. Please Help. Thanks Advance
I search the above question all over the internet and no result found
Please anybody help me...
Like, what, these buildings would be non-existent at the moment of the creation of your webplayer. And you would want to be able to add new buildings that could be used by the webplayer?
Answer by Joyrider · Aug 12, 2013 at 07:17 AM
I see two options
1/ ASSET BUNDLES
You could use Unity's AssetBundles and Building AssetBundles
It would require you to have Unity Pro though; and is the only way to stream new ready-to-be-used models into Unity (scripts are not supported, so all your logic has to be in your original player).
Here is also an interesting read for how to use them for web builds in order to avoid the 50Mb (or otherwise indicated) cache size limit.
You can either have one assetbundle with all your assets
or a textfile listing all your objects on a server, and have a seperate assetbundle for each object, that you can download according to what the user wants to access. Avoiding to have to download everything at once.
2/ RUNTIME OBJECT GENERATION
There is one other option, but I do not think that is what you have in mind. The second possibility would be to download a textasset that contains all data relevent to the creation of your model, and to construct the model yourself. So this is a little more complicated. After which you could download the textures you need for the model. Note that all the shaders you would use, would need to be already in your original export as well.
Thanks for your reply
$$anonymous$$y is to create a building, then the user can add new features at runtime.
What I need is a GUI with the available items from a folder. Then when pressing an item in the GUI, I can create an instance of the item.
Hovering over the building, the item may be placed in specific locations. for instance, user may not place a door on the roof. Once user hovering over an appropriate location, he is allowed to release and place the texture or furniture.
Can I achieve that? Please Help. Thanks Advance
What kind of items in your folder?
Would you be the one to add the items to be accessible by the user, or do you want the user to add these items themselves?
Answer by Bunny83 · Aug 12, 2013 at 09:31 AM
The webplayer can't access any folder from the users filesystem for security reasons. There is no way around that. You have to load any stuff from your webserver where your game/application is hosted.
I was getting to that ;) But my guess is Assetbundels does what he needs.
Not from user filesystem. I want my application to load stuffs that I already added in the webserver, so that user can use that.
$$anonymous$$y stuffs are furniture, texture etc
Not really, if your assets are already in your game, like you said, you don't have to load them dynamically. Just Instantiate them
Hence my original comment on the question... it all depends if he wants to update his assets after generation of the webplayer or not. If not, than it is indeed fairly easy ;)
Answer by Deepschalappatta · Aug 29, 2013 at 07:33 AM
Try this link. http://stackoverflow.com/questions/18438193/assetbundle-and-load-object-in-unity3d.
instead of caheload.js you just try this code
#pragma strict
function Start ()
{
var www = WWW.LoadFromCacheOrDownload ("file://C:/wamp/www/object/monkey.unity3d",4.2);
yield www;
// print("hai"+www);
if (!String.IsNullOrEmpty(www.error))
{
Debug.Log (www.error);
return;
}
var myLoadedAssetBundle = www.assetBundle;
//print("hai"+myLoadedAssetBundle);
var asset = myLoadedAssetBundle.mainAsset;
//print("hai"+asset);
Instantiate(asset);
print("its me" +asset);
}
The Link is now not a valid which you provided. Please share some other links.
Your answer
Follow this Question
Related Questions
Loading of assets during runtime 0 Answers
what is the best way to implement minigames into my own full blown unity game. 0 Answers
Asset creator in Unity 2 Answers
How can I load 3d models(.obj, .fbx) dynamically in to unity scene after building it to WebGL ? 1 Answer
Why can't I build Web Player in Unity while I have no problems with building standalone versions? 2 Answers