loading a new Object in the scene Runtime.

Hello Unityrs,

I would like to know if in Unity it is possible to load a new geometry in the scene once a button has been clicked. Something that opens a FileDialog, allows selecting a geometry, you click ok and the geometry is in.

My second question is: if unity hasn’t the feature mention before, I can do it with Javascript in a webpage, but then, can I have the access to the features in unity from the web page using the HTML DOM or/and Ajax?

Many thanks.
Giancarlo

Yeah that should be done quite easy.

Sample code :

	if (GUI.Button (Rect (20,95,80,20), "Create")) 
        {
                Instantiate(somePrefab, 
					position , 
					rotation);
	}

This is a basic creation. You can further improve it by popping a submenu in which you can choose prefab ( geometry ), location, rotation and whatever else you need.

Hey Thank you so much.
But where you say “somePrefab” can I also pass a path to some pre-save prefab? if I load load a multiple prefabs in the same scene without having the scene reset to an empty one first?

GC.

I’m not exactly sure what do you mean. But Yes somePrefab stands for one of your prefabs and there is no need to reset the scene to an empty one.

Got that! :slight_smile:

Thank you very much!

GC.