Unity UIWidgets - 第1篇 HelloWorld


    這里演示如何寫一個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));
        }
    }
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM