您的位置:首页 > 移动开发 > Unity3D

Unity3D单击物体弹出GUI窗口

2013-10-14 11:10 465 查看
功能:

1.显示视窗及关闭视窗功能

2.单击物体弹出GUI窗口 

view plaincopy to clipboardprint?

   1. static var WindowSwitch : boolean = false;  

   2. var mySkin : GUISkin;  

   3. var windowRect = Rect (200, 80, 240, 100);  

   4. function OnGUI ()  

   5. {  

   6.    if(WindowSwitch ==  true)  

   7.    {  

   8.       GUI.skin = mySkin;  

   9.         windowRect = GUI.Window (0, windowRect, WindowContain, "测试视窗");  

  10.    }  

  11. }  

  12. function WindowContain (windowID : int)  

  13. {  

  14.     if (GUI.Button (Rect (70,40,100,20), "关闭视窗"))  

  15.    {  

  16.       WindowSwitch = false;  

  17.    }  

  18. }  

static var WindowSwitch : boolean = false; var mySkin : GUISkin; var windowRect = Rect (200, 80, 240, 100); function OnGUI () { if(WindowSwitch == true) { GUI.skin = mySkin; windowRect = GUI.Window (0, windowRect, WindowContain, "测试视窗"); } } function WindowContain
(windowID : int) { if (GUI.Button (Rect (70,40,100,20), "关闭视窗")) { WindowSwitch = false; } } 

view plaincopy to clipboardprint?

   1. function OnMouseEnter ()  

   2. {  

   3.     renderer.material.color = Color.red;  

   4. }  

   5. function OnMouseDown ()  

   6. {  

   7.    Func_GUIWindow.WindowSwitch = true;  

   8. }  

   9. function OnMouseExit ()  

  10. {  

  11.    renderer.material.color = Color.white;  

  12. }  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: