通过点击文本来触发事件。点击文本后在控制台打印信息。

  本篇在第1篇基础上实现。

效果图:

  Unity UIWidgets - 第2篇 点击事件

代码部分:

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"); }
                );
        }
    }
}

 

相关文章:

  • 2021-06-21
  • 2021-12-22
  • 2022-12-23
  • 2021-05-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-08
  • 2022-01-07
  • 2022-01-21
相关资源
相似解决方案