這里演示如何寫一個HelloWorld。
先看效果圖:

效果就是在Game視圖顯示HelloWorld。
做法:
1.新建場景HelloWorld,腳本HelloWorld。
2.刪除相機和燈光,加上Panel。把panel的Image組件刪除了。
3.加一個HelloWorld到Panel上。

代碼部分:
using Unity.UIWidgets.engine; using Unity.UIWidgets.painting; using Unity.UIWidgets.ui; using Unity.UIWidgets.widgets; namespace LearnUIWidgets { public class HelloWorld : UIWidgetsPanel { protected override Widget createWidget() { // 返回白色、字號30的Hello World return new Text(data: "Hello World", style: new TextStyle(color: Color.white, fontSize:30)); } } }
