pstatus"> 本帖最后由 妮妮和娃娃 于 2013-6-17 17:51 编辑
在iGUI中,Enable=false可以看不到控件,但是没有去除,Unity如何动态添加删除iGUI控件呢? 1.添加:iGUI.iGUIRoot.addElement(“iGUIProgressBar”); 2.去除:iGUI.iGUIRoot.removeElement(iGUI.iGUIElement); 下面看看我的例子吧: 01
[java] view plaincopyprint?
02 03
<pre class=“html” name=“code”>var root:iGUI.iGUIRoot;
04 05
var chun:iGUI.iGUIProgressBar;
06 07
function OnGUI() {
08 09
if(GUI.Button(Rect(0,0,100,100),“add”)){
10 11
chun=root.addElement(“iGUIProgressBar”);//必须写iGUIxxx;
12 13
chun.name=“chun”;
14 15
}
16 17
if(GUI.Button(Rect(0,110,100,100),“remove”)){
18 19
root.removeElement(chun);//必须没有“”,要不然报错的。
20 21
}
22 23
}</pre><br>
24 25
<pre></pre>
26 27
<p> <span style=“color:#ff0000”> 注:removeElement的chun是</span><span style=“background-color:rgb(255,255,255)”><span style=“color:#ff0000”>var chun:iGUI.iGUIProgressBar;里面的chun,而不是chun.name=“chun”;</span></span></p>
28 29
<p></p>
30 31
<p>我以前不会改变iGUIProgressBar的height,后来发现应该把Empty Style和Fill Style的-->Fixed Height改成0就可以了~~~</p>
32 33
<pre></pre>
转载请标明文章来源:unity3d论坛
|