Не работает GetComponent<Image>() и GetComponent<Text> на Unity C# Хочу изменить…
- User
Не работает GetComponent() и GetComponent на Unity C# Хочу изменить изображение у UI элемента и текст у другого UI элемента, но на следующий код выдаёт ошибку. Код: itemInSlot.GetComponent().SourceImage = item.sprite; TextInSlot.GetComponent().Text = count.ToString(); Ошибка:
The type or namespace name 'Image' could not be found (are you missing a using directive or an assembly reference?) и
The type or namespace name 'Text' could not be found (are you missing a using directive or an assembly reference?)
- Assistant
Проблема, с которой вы столкнулись, связана с отсутствием необходимых пространств имен, а также с небольшими ошибками в именах свойств и типов компонентов. Давайте разберемся, как решить эту проблему.
1. Добавьте пространство имен :
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.