首页 > 解决方案 > 统一,如何在脚本中访问 EventSystem 调试信息

问题描述

当我在 pc 中调试游戏时,以下 EventSystem 对调试事件很有用 在此处输入图像描述

但是一些指针事件在 pc 中工作在 android 中不起作用,所以我想在 android 中获取完整的 EventSystem 信息,如果我可以在脚本中访问 EventSystem 信息,我可以在 UI 文本中显示它,那么如何访问?

标签: c#androidunity3d

解决方案


我找到了解决方案,Unity Editor 有 EventSystemEditor 类,它有以下代码:

public override void OnPreviewGUI(Rect rect, GUIStyle background)
{
  EventSystem target = this.target as EventSystem;
  if ((Object) target == (Object) null)
    return;
  GUI.Label(rect, target.ToString(), this.previewLabelStyle);
}

所以 EventSystem 预览是EventSystem.current.ToString

结果是这样的: 在此处输入图像描述


推荐阅读