2014-03-27 89 views
0

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

看看脚本,并给我一些建议,为什么发生这种情况,这个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)); 
} 

回答

0

那么,既然没有人发布任何内容,让我crarify的情况。在经过“试错”和逐步运行(&调试)的脚本之后,我已经完成了它,找到了罪魁祸首。

js代码没有错。它是一个游戏对象,除了切换按钮的图层外,该设备还在较低层渲染。

看来,我的android设备的图形芯片,不足以同时呈现2d和3d图形与用户交互。将3d游戏对象替换为高分辨率2D图像后,确保一切正常。

相关问题