[Unity] 脚本中设置了 SerializeField 标签的 Image UI 组件没有显示在编辑器的 Inspector 中的解决办法

338 阅读1分钟

参考

forum.unity.com/threads/can…

问题

如下代码可能在在编辑器的 Inspector 中没有显示 Image 组件

[SerializeField]
private Image tipImage;

原因

可能是因为你使用的 IDE 给你加上了

using Image = UnityEngine.UIElements.Image;

其实只需要用 UnityEngine.UI 不要用 UnityEngine.UIElements.Image 就好了

using UnityEngine.UI;

这两个 Image 是不相同的