
Click the GUI to create the model in the scene. Creation process, the model has been attached to the mouse, how to achieve it? Thank you!

The above is what I do, I have two questions
- I can not follow the model created the position of the mouse
- If I were the terrain is level, the model can attached on the surface of the terrain
Thank you!
-
private var moxing1 :boolean=false;
-
private var moxing2 :boolean=false;
-
private var moxing3 :boolean=false;
-
private var moxing4 :boolean=false;
-
private var moxing5 :boolean=false;
-
var moxing1mesh : MeshFilter;
-
var moxing2mesh : MeshFilter;
-
var moxing3mesh : MeshFilter;
-
var moxing4mesh : MeshFilter;
-
var moxing5mesh : MeshFilter;
-
var moxing1_1 :GameObject;
-
var moxing2_1 :GameObject;
-
var moxing3_1 :GameObject;
-
var moxing4_1 :GameObject;
-
var moxing5_1 :GameObject;
-
private var windowRect1:Rect=Rect(0,0,200,200);
-
var scrollPosition : Vector2 = Vector2.zero;
-
var map :RenderTexture;
function Start () {
}
function OnGUI () {
windowRect1=GUI.Window(0,windowRect1,mywindow,“”);
}
function mywindow (windowID :int)
{
GUI.Box(Rect(10,20,90,90),map);
scrollPosition=GUI.BeginScrollView(Rect(110,20,80,90),scrollPosition,Rect(0,0,0,250));
moxing1=GUI.Toggle(Rect(0, 10, 100, 30), moxing1, "model1");
if(moxing1)
{
moxing1mesh.mesh =new GameObject.Find ("moxing1mesh").GetComponent(MeshFilter).mesh;
moxing2=false;
moxing3=false;
moxing4=false;
moxing5=false;
}
moxing2=GUI.Toggle(Rect(0, 30, 100, 30), moxing2, "model2");
if(moxing2)
{
moxing1mesh.mesh =GameObject.Find ("moxing2mesh").GetComponent(MeshFilter).mesh;
moxing1=false;
moxing3=false;
moxing4=false;
moxing5=false;
}
moxing3=GUI.Toggle(Rect(0, 50, 100, 30), moxing3, "model3");
if(moxing3)
{
moxing1mesh.mesh =GameObject.Find ("moxing3mesh").GetComponent(MeshFilter).mesh;
moxing1=false;
moxing2=false;
moxing4=false;
moxing5=false;
}
moxing4=GUI.Toggle(Rect(0, 70, 100, 30), moxing4, "model4");
if(moxing4)
{
moxing1mesh.mesh =GameObject.Find ("moxing4mesh").GetComponent(MeshFilter).mesh;
moxing1=false;
moxing2=false;
moxing3=false;
moxing5=false;
}
moxing5=GUI.Toggle(Rect(0, 90, 100, 30), moxing5, "model5");
if(moxing5)
{
moxing1mesh.mesh =GameObject.Find ("moxing5mesh").GetComponent(MeshFilter).mesh;
moxing1=false;
moxing2=false;
moxing3=false;
moxing4=false;
}
GUI.EndScrollView();
if(GUI.Button(Rect(10,130,80,30),"CreatModel"))
{
if(moxing1)
{
var moxing1_1_1:GameObject = Instantiate(moxing1_1,Vector3(0,10,0),Quaternion.identity);
}
if(moxing2)
{
var moxing2_1_1:GameObject = Instantiate(moxing2_1,Vector3(0,10,0), Quaternion.identity);
}
if(moxing3)
{
var moxing3_1_1:GameObject = Instantiate(moxing3_1,Vector3(0,10,0), Quaternion.identity);
}
if(moxing4)
{
var moxing4_1_1:GameObject = Instantiate(moxing4_1,Vector3(0,10,0), Quaternion.identity);
}
if(moxing5)
{
var moxing5_1_1:GameObject = Instantiate(moxing5_1,Vector3(0,10,0), Quaternion.identity);
}
}
GUI.DragWindow(Rect(0,0,10000,10000));
}
The above is to create a model code. Thankyou!!