Created
November 30, 2020 20:21
-
-
Save tubakihimeLoveHate/e34ef1a559789563497ebcc7edff8b2e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEngine.UI; | |
public class CreatePinPoint : MonoBehaviour | |
{ | |
[SerializeField] | |
private float distance = 20.0f; | |
[SerializeField] | |
private GameObject pinPoint; | |
// Update is called once per frame | |
void Update() | |
{ | |
if (Input.GetMouseButtonUp(0)) | |
{ | |
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); | |
RaycastHit hit; | |
if (Physics.Raycast(ray, out hit, distance)) | |
{ | |
Instantiate(pinPoint, hit.point,Quaternion.identity); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment