纳金网

标题: 点击立方体弹出GUI窗口的代码 [打印本页]

作者: 王者再临    时间: 2014-12-31 22:11
标题: 点击立方体弹出GUI窗口的代码

给立方体挂上下面javascript代码,运行即看到效果
  1. #pragma strict

  2.  static var WindowSwitch : boolean = false;

  3.  var mySkin : GUISkin;

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

  5.  function OnGUI ()

  6.  {

  7.  if(WindowSwitch ==  true)

  8.  {

  9.  GUI.skin = mySkin;

  10.  windowRect = GUI.Window (0, windowRect, WindowContain, “打开视窗”);

  11.  }

  12.  }

  13.  function WindowContain (windowID : int)

  14.  {

  15.  if (GUI.Button (Rect (70,40,100,20), “关闭视窗”))

  16.  {

  17.  WindowSwitch = false;

  18.  }

  19.  }

  20.  function OnMouseEnter ()

  21.  {

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

  23.  }

  24.  function OnMouseDown ()

  25.  {

  26.  WindowSwitch = true;

  27.  }

  28.  function OnMouseExit ()

  29.  {

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

  31.  }
复制代码





欢迎光临 纳金网 (http://wwww.narkii.com/club/) Powered by Discuz! X2.5