Сергей Predictor
Профи
(544)
6 дней назад
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class SelectionManager : MonoBehaviour
{
public GameObject interaction_Info_UI;
private TMP_Text interaction_text;
private InteractableObject currentInteractable;
private void Start()
{
interaction_text = interaction_Info_UI.GetComponent<TMP_Text>();
interaction_Info_UI.SetActive(false); // Изначально скрыть UI
}
void Update()
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
{
var selectionTransform = hit.transform;
InteractableObject interactable = selectionTransform.GetComponent<InteractableObject>();
if (interactable)
{
if (currentInteractable != interactable) // Проверка на изменения
{
currentInteractable = interactable;
interaction_text.text = currentInteractable.GetItemName();
interaction_Info_UI.SetActive(true);
}
}
else
{
if(currentInteractable != null)
{
currentInteractable = null;
interaction_Info_UI.SetActive(false);
}
}
}
else
{
if(currentInteractable != null)
{
currentInteractable = null;
interaction_Info_UI.SetActive(false);
}
}
}
}
Мне выводит ошибку -