簡體   English   中英

如何在 Unity 2019.3 中獲取對圖像的引用?

[英]How do I get a reference to an Image in Unity 2019.3?

所以通常在 Unity 中,我可以使用GetComponent<Type>()獲取對游戲對象上組件的引用。 在這種情況下,我想做一個簡單的GetComponentInChildren<Image>()以便我可以對圖像執行一些代碼。 正常的團結的東西。

但是在 2019.3 中,我似乎不能這樣做,因為Image不再是一個組件。

ArgumentException: GetComponent requires that the requested component 'Image' derives from MonoBehaviour or Component or is an interface.

所以我不確定如何在 RectTransform 上獲得對圖像“組件”的引用,以便對其進行處理。 有任何想法嗎?

愚蠢的回答,但我想通了。 離開這里為子孫后代。

我的Image類型被錯誤地定義為Unity.UIElements.Image而不是我想要的Unity.UI.Image 有兩個同名的不同類非常酷。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM