2015-01-21 50 views
0

我想要在Canvas上獲得對圖形Raycaster的引用,以便可以啓用/禁用它。這是我在做什麼:爲什麼我不能在我的gameObject中引用Graphic Raycaster?

shopCanvas.GetComponent<GraphicRaycaster>().enabled = false; 

當我將鼠標懸停在上面的代碼中的MonoDevelop它說

「這個名字GraphicRaycaster不會在當前的背景下存在」當我嘗試編譯和運行遊戲我得到這個錯誤:

error CS0246: The type or namespace name `GraphicRaycaster' could not be found. Are you missing a using directive or an assembly reference?

這是我設置的PIC:

enter image description here

+0

'CS0246'通常在鼻子上。您是否驗證過推薦您驗證的內容?看起來類型'GraphicRaycaster'在上下文中不可用,或者是因爲缺少'using'指令(會導入其名稱空間),或者因爲您甚至沒有引用聲明該類型的DLL。 – 2015-01-21 05:54:07

回答

3

只需添加:

using UnityEngine.UI; 

到C#代碼文件和編譯器的開頭會發現GraphicRaycaster

相關問題