作者su31o4gj83 (哈哈哈哈哈哈哈哈哈哈哈)
看板GameDesign
标题Re: [请益] [程式] Unity换背景
时间Thu Sep 1 23:30:57 2011
※ 引述《kingworld (珊夜 薰)》之铭言:
: 自己觉得程式码应该没有问题
: (好像程式有问题的人都会这样说)
: 是希望在同一个场景里面
: 按下一个按钮之後 它的图片/背景会换成另外一张图
: 是用javascript写的
: 以下是程式码
你这段程式码的逻辑是
: -----------------------------------------------------------------
: var aTexture : Texture2D;
: function OnGUI() {
: if(GUI.Button(Rect(0,0,100,20),"AAA")){
如果按下按钮
: GUI.DrawTexture(Rect(0,0,Screen.width,Screen.height), aTexture, ScaleMode.StretchToFill, true,0);
: print("AAA");
画一张图, 接着 print("AAA")
: }
: }
所以只画了一次
应该改成类似
var draw : boolean
function OnGUI ()
{
if (draw)
GUI.DrawTexture(....)
if (GUI.Button(...))
draw = ! draw;
}
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 118.167.193.244