Skip to content

Instantly share code, notes, and snippets.

@tubakihimeLoveHate
Created November 30, 2020 20:21
Show Gist options
  • Save tubakihimeLoveHate/e34ef1a559789563497ebcc7edff8b2e to your computer and use it in GitHub Desktop.
Save tubakihimeLoveHate/e34ef1a559789563497ebcc7edff8b2e to your computer and use it in GitHub Desktop.
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