31 lines
696 B
C#
31 lines
696 B
C#
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
|
||
|
public class CameraSlotClickDetect : MonoBehaviour
|
||
|
{
|
||
|
public Camera mainCamera;
|
||
|
public LayerMask layerMask;
|
||
|
|
||
|
void Update()
|
||
|
{
|
||
|
if (Input.GetMouseButtonDown(0))
|
||
|
{
|
||
|
ShootRay();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void ShootRay()
|
||
|
{
|
||
|
Ray ray = mainCamera.ScreenPointToRay(Input.mousePosition);
|
||
|
RaycastHit hit;
|
||
|
|
||
|
if (Physics.Raycast(ray, out hit, Mathf.Infinity, layerMask))
|
||
|
{
|
||
|
var slotInfo = hit.collider.gameObject.GetComponentInParent<SlotManager>();
|
||
|
|
||
|
Debug.Log($"Hit PlacementSlot! At ({slotInfo.x}, {slotInfo.y})");
|
||
|
}
|
||
|
}
|
||
|
}
|