經過點擊文原本觸發事件。點擊文本後在控制檯打印信息。ide
本篇在第1篇基礎上實現。ui
效果圖:spa
代碼部分:3d
using Unity.UIWidgets.engine; using Unity.UIWidgets.painting; using Unity.UIWidgets.ui; using Unity.UIWidgets.widgets; using UnityEngine; namespace LearnUIWidgets { public class HelloWorld : UIWidgetsPanel { protected override Widget createWidget() { return new GestureDetector( child: new Text(data: "OnClick", style: new TextStyle(color: Unity.UIWidgets.ui.Color.white, fontSize: 30)), onTap: ()=> { Debug.Log(message: "onTap"); } ); } } }