- 最后登录
- 2016-8-29
- 注册时间
- 2012-8-25
- 阅读权限
- 90
- 积分
- 23585
- 纳金币
- 20645
- 精华
- 62
|
给立方体挂上下面javascript代码,运行即看到效果- #pragma strict
-
- 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;
-
- }
-
- }
-
- function OnMouseEnter ()
-
- {
-
- renderer.material.color = Color.red;
-
- }
-
- function OnMouseDown ()
-
- {
-
- WindowSwitch = true;
-
- }
-
- function OnMouseExit ()
-
- {
-
- renderer.material.color = Color.white;
-
- }
复制代码 |
|