Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class BuildManager : MonoBehaviour
- {
- public Camera mainCam;
- public GameObject prevObj;
- public GameObject currObj;
- private void Update()
- {
- if (Input.GetKeyDown(KeyCode.Mouse0))
- {
- clickToGrid();
- }
- }
- private void clickToGrid()
- {
- Vector3 pos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0);
- Ray ray = mainCam.ScreenPointToRay(pos);
- RaycastHit hit;
- Debug.DrawRay(ray.origin, ray.direction * 10, Color.yellow);
- if (Physics.Raycast(mainCam.ScreenPointToRay(pos), out hit, 10))
- {
- Debug.Log(hit.transform.name);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement