【问题标题】:GUI.Toggle button in Unity does not close pop up windowUnity 中的 GUI.Toggle 按钮不会关闭弹出窗口
【发布时间】:2014-05-06 22:22:11
【问题描述】:

我有以下脚本来打开一个 GUI.Window 作为带有切换按钮的弹出窗口。在 Unity3d 编辑器播放器中,脚本运行正常,单击切换按钮时窗口打开关闭。 当我将场景编译到我的 Android 设备时,脚本会运行,但我只能使用触摸切换按钮打开 GUI.Window,并且再次触摸按钮时无法关闭它。

看看脚本,给我一些建议为什么会这样,这个 UnityScript 有什么问题?提前谢谢大家。

这是脚本:

#pragma strict
private var doWindow0 : boolean = false;
var aTexture : Texture;
var wTexture : Texture;

// Make the contents of the window.
function DoWindow0 (windowID : int) {
    GUI.color = Color.cyan;     
    GUI.Box (new Rect (10,10,415,210),wTexture);

}

function OnGUI () {
    if(!aTexture) {
        Debug.LogError("Please assign a texture in the inspector.");
        return;
    }
    // Make a toggle button for hiding and showing the window

    doWindow0 = GUI.Toggle(Rect(210,210,70,20), doWindow0, aTexture);
    //doWindow0 = GUI.Button (new Rect (10,10,100,20), doWindow0, "InfoBox");

    // Make sure we only call GUI.Window if doWindow0 is true.
    if (doWindow0)
        GUI.Window (0, Rect (30,0,420,215), DoWindow0, "InfoBox");

    // Make the windows be draggable.
    GUI.DragWindow (Rect (0,0,10000,10000));
}

【问题讨论】:

    标签: android user-interface unity3d popupwindow unityscript


    【解决方案1】:

    好吧,既然还没有人发布任何东西,让我澄清一下情况。在通过“反复试验”进行深入研究并逐步运行(和调试)发布的脚本之后,我终于找到了罪魁祸首。

    js代码没有错。它是一个 GameObject,除了切换按钮的层之外,呈现在较低层上的设备。

    我的安卓设备的图形芯片似乎不够强大,无法在用户交互的同时渲染 2d 和 3d 图形。将 3d GameObject 替换为高清 2d 图像后,一切正常。

    【讨论】:

      猜你喜欢
      • 2015-09-22
      • 2014-10-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多