GetComponent 找不到 UnityUI Image 组件

Cor*_*non 1 c# unity-game-engine

UnityUI Image 组件不是从 Monobehaviour Component 派生的,也不是一个接口,那么我如何在脚本中访问它呢?我尝试了 .GetComponent,但它告诉我它不能这样做,因为上面的语句:/

经过 1.5 小时的谷歌搜索后,我能找到的唯一“解决方案”已经完全过时了(界面已更改)

我的控制台错误:

ArgumentException: GetComponent requires that the requested component 'Image' derives from MonoBehaviour or Component or is an interface.
UnityEngine.GameObject.GetComponent[T] () (at <05f2ac9c8847426992765a22ef6d94ca>:0)
GUIController.Start () (at Assets/UI/Scripts/GUIController.cs:41)
Run Code Online (Sandbox Code Playgroud)

我想使用的代码:

Image menueImage1 = menueButton1.transform.Find("Cap").gameObject.GetComponent<Image>();
Run Code Online (Sandbox Code Playgroud)

“您导​​入了UnityEngine.UIElements吗?” -> 是的

Unity版本:2019.3.10f1

“组件”在本地文档中的位置:Unity/2019.3.10f1/Editor/Data/Documentation/en/Manual/script-Image.html 我附上了“组件”的图片。

任何帮助将不胜感激:)

我说的是“图像”脚本

Lot*_*tan 5

问题是你的输入。

你不想用UnityEngine.UIElements,​​你就想用UnityEngine.UI