现在的位置: 首页 > 综合 > 正文

Unity3D单击物体弹出GUI窗口

2014年01月26日 ⁄ 综合 ⁄ 共 718字 ⁄ 字号 评论关闭

功能:

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

2.单击物体弹出GUI窗口 

[javascript] view
plain
copy

  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. }  

 

[javascript] view
plain
copy

  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. }  

抱歉!评论已关闭.