簡體   English   中英

腳本化的GUI按鈕未出現在Android上

[英]Scripted GUI button doesn't appear on Android

我正在使用Unity開發跨平台應用程序。

我正在使用以下C#代碼在屏幕上放置一個按鈕:

void onGUI()
    {
        float texWidth = m_buttonPano.normal.background.width;
        float texHeight = m_buttonPano.normal.background.height;

        float width = texWidth * Screen.width / 1920;

        float height = (width / texWidth) * texHeight;
        float y = Screen.height - height;
        float x = Screen.width - width;
        if (GUI.Button (new Rect (x, y, width, height), "", m_buttonPano)) {
            if (this.TappedOnPanoButton != null) {
                this.TappedOnPanoButton ();
            }
            m_guiInput = true;
        }
    }

還要注意,我通過創建一個空的GameObject並將腳本附加到場景中來將此腳本添加到場景中。

它在PC上運行良好,但在Android上沒有顯示該按鈕。 有趣的是,如果我點擊它的位置(右下角),該功能將保留,因此只有我放在其上的自定義背景紋理不會顯示。

另外,這是背景紋理的附件代碼:

m_buttonPano = new GUIStyle();
m_buttonPano.normal.background = Resources.Load("GUI/buttonPano") as Texture2D;
m_buttonPano.active.background = Resources.Load("GUI/buttonPano") as Texture2D;
m_buttonPano.onActive.background = Resources.Load("GUI/buttonPano") as Texture2D;

問題實際上是Unity錯誤。 下載f4補丁后,一切正常。

暫無
暫無

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

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