使用版本: Unity 5.6.0
發生狀況: 畫面UI使用滑鼠或觸控無反應
GameObject obj = new GameObject();
Button button = new GameObject("Button").gameObject.AddComponent<Button>();
button.transform.SetParent(obj.transform, false);
button.gameObject.AddComponent<Image>();
在這個地方如果是先使用SetParent再AddComponent<Image>(),
則會發生全畫面互動無效化的問題,
問題發生後,即使將該元件關閉,仍無法恢復其他元件的互動.
修正方式: 將加入順序調整
GameObject obj = new GameObject();
Button button = new GameObject("Button").gameObject.AddComponent<Button>();
button.gameObject.AddComponent<Image>();
button.transform.SetParent(obj.transform, false);
目前測試過5.6.0與5.3.2,只有在5.6.0上會發生此狀況.
另外,
比較常見的類似問題原因,是少加了EventSystem.
(可透過在Hierarchy上新增Image來自動生成)
訂閱:
張貼留言 (Atom)
[Unity] Odin Inspector DateTime 時間屬性繪製
Odin Inspector 是一個有名的Unity Inspector Plugin,但沒有為 DateTime 建立可編輯的可視化介面,這邊簡單提供一個可用的方法 。 Odin Inspector 版本 : 3.3.1.14
-
IP Messenger 4.99r3 繁體中文版 介紹:方便區網內傳輸的小工具,又名飛鴿傳書。 支援文字、圖片、檔案、資料夾點對點傳輸。
-
使用環境 : Visual Studio Community 2019 錯誤訊息 : 錯誤 NETSDK1004 找不到資產檔案 '...\obj\project.assets.json'。請執行 NuGet 套件還原,以產生此檔案。
-
Cocos Creator 編譯Android APK失敗的可能原因 Execution failed for task Cocos Creator 版本: 2.3.1 NDK版本:r21 Android SDK:29 編譯方式: default 問題: Windows...
沒有留言:
張貼留言