最近在學習代碼創建UI,,遇到一個問題就是創建的GUI,Window不知道怎么設定文本內容,例如
public Rect windowRect = new Rect(20, 20, 120, 50);
void OnGUI() {
windowRect = GUI.Window(0, windowRect, DoMyWindow, "My Window");
}
void DoMyWindow(int windowID)
{
GUI.DragWindow(new Rect(0, 0, 120,50));
}
像這樣得到的只是這個視窗的標題文字My Window“”,創建不了文本內容.
請教一下各位,感激不盡
uj5u.com熱心網友回復:

window里的內容,你需要繼續寫啊,應該是寫在DoMyWindow 函式里,比如GUI.Label啊 GUI.Button啊等等……
uj5u.com熱心網友回復:
http://blog.csdn.net/a958832776/article/details/70792607uj5u.com熱心網友回復:
private void CreateConsole(){
GUILayout.BeginArea(new Rect(5, 20, 400, 200));
scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Width(400), GUILayout.Height(200));
GUILayout.Label("this is an apple");
//添加一個布局按扭。手動洗掉
if (GUILayout.Button("clear"))
{
//todo
}
// 用EndScrollView結束上面開始的滾動框。
GUILayout.EndScrollView();
GUILayout.EndArea();
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/61356.html
標籤:Unity3D
上一篇:類蛇蛇大作戰 相機跟隨玩家,怎么實作蛇移動時食物不會閃爍,平滑移動; 蛇蛇大作戰 怎么實作蛇移動時食物不會閃爍,平滑移動,那么多食物
