Using System.Collections;
Using System.Collections.Generic;
Using Unityengine;
Using Unityengine.ui;
public class Build:monobehaviour {
Public Gameobject Camera_main;
Public Gameobject Camera_front;
public int cameraflag;
Public Vector3 POS;
Public Gameobject Abuild;
Public Dropdown DRP;
public float x, y;
public float speed= 10.0f;
void Start ()
{
Camera_main = Gameobject.find ("Camera");
Camera_front = Gameobject.find ("Camera_front");
Camera_front. SetActive (FALSE);
Cameraflag = 1;
}
void Update () {
Rotate the model by holding down the left mouse button
if (Input.getmousebutton (0) &&abuild!=null)
{
Left mouse button to move
y = Input.getaxis ("Mouse X") * time.deltatime * speed;
x = Input.getaxis ("Mouse Y") * time.deltatime * speed;
Abuild.transform.Rotate (New Vector3 (x, y, 0));
}
Keyboard to move the model around the next key
if (Input.getaxis ("horizontal")! = 0 && Abuild! = null)
{
Abuild.transform.Translate (Input.getaxis ("Horizontal") * 3, 0, 0);
}
if (Input.getaxis ("Vertical")! = 0 && Abuild! = null)
{
Abuild.transform.Translate (0, 0,input.getaxis ("Vertical") * 3);
}
The mouse pulley realizes the model's contraction
if (Input.getaxis ("Mouse scrollwheel")! = 0)
{
Abuild.transform.localScale + = new Vector3 (Input.getaxis ("Mouse scrollwheel"), Input.getaxis ("Mouse scrollwheel"), Input.getaxis ("Mouse scrollwheel"));
}
If (Input.getmousebuttondown (1) && cameraflag > 0)
{
Ray Ray = Camera.main.ScreenPoin Ttoray (input.mouseposition);
Raycasthit hit;
if (Physics.raycast (Ray, out-hit))
{
pos = hit.point;
if (Hit.transform.gameObject.name = = "Plane")
Pick = Gameobject.instantiate (Resources.load ("Checked"), POS, TRANSFO rm.rotation) as Gameobject;
Else
{
Debug.Log ("Checked Object! ");
Abuild = Hit.transform.gameObject;
}
}
}
//Implementing a function to convert between cameras
public void Changecamera ()
{
Cameraflag =-camerafla G
if (Cameraflag > 0)
{
Camera_main. SetActive (TRUE);
Camera_front. SetActive (FALSE);
}
Else
{
Camera_main. SetActive (FALSE);
Camera_front. SetActive (TRUE);
Abuild = null;
}
}
}
Unity3d Click a button to achieve the conversion between the camera, click on the added object, and use the keyboard for mobile, mouse rotation, zoom operation