Skip to content
Permalink
4ac3176be9
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
30 lines (22 sloc) 624 Bytes
using UnityEngine;
using System.Collections;
public class MouseController : MonoBehaviour
{
Ray ray;
RaycastHit hit;
public GameObject prefab;
void Update ()
{
ray = Camera.main.ScreenPointToRay (Input.mousePosition);
if (Physics.Raycast (ray, out hit)) {
if (Input.GetKeyDown (KeyCode.Mouse0)) {
Debug.Log ("Left Mouse Down");
GameObject obj = Instantiate (prefab, new Vector3 (hit.point.x, hit.point.y, hit.point.z), Quaternion.identity) as GameObject;
}
if (Input.GetKeyDown (KeyCode.Mouse1)) {
Debug.Log ("Righ Mouse Down");
Destroy(hit.transform.gameObject);
}
}
}
}