Unity C# ошибка в коде программы
Кто знает где ошибка в этом скрипте?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class SelectionManager : MonoBehaviour
{
public GameObject interaction_Info_UI;
TMP_Text interaction_text;
private void Start()
{
interaction_text = interaction_Info_UI.GetComponent<TMP_Text>();
}
void Update()
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
{
var selectionTransform = hit.transform;
if (selectionTransform.GetComponent<InteractableObject>())
{
interaction_text.text = selectionTransform.GetComponent<InteractableObject>().GetItemName();
interaction_Info_UI.SetActive(true);
}
else
{
interaction_Info_UI.SetActive(false);
}
}
}
}
Мне выводит ошибку -
Assets\SCRIPTS\SelectionManager.cs(28,69): error CS0246: The type or namespace name 'InteractableObject' could not be found (are you missing a using directive or an assembly reference?)
>Кто знает где ошибка в этом скрипте?
Ну я знаю. В 28-ой строке. Помогло?
может быть ты забыла поставить точку с запятой или скобки не закрыла проверь код
слушай если ошибка связана с переменной посмотри не забыл ли ты её объявить
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);
}
}
}
}