using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ItemSelector : MonoBehaviour
{
[SerializeField]
private Camera cam;
private InteractableItem selected;
private LayerMask mask;
public static ItemSelector instance;
private float range = 1;
public InteractableItem Selected { get { return selected; } }
// Start is called before the first frame update
void Start()
instance = this;
}
void FixedUpdate()
Ray ray = cam.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit,range,layerMask:mask))
if(selected!= null||hit.transform.gameObject==null)
selected.Disable();
selected = hit.transform.gameObject.GetComponent<InteractableItem>();
selected.Enable();
print(selected);
else
if (selected != null)
// Update is called once per frame
void Update()