EditorDebuggerPlugin

继承: RefCounted < Object

实现调试器插件的基类。

描述

编辑器调试器插件 EditorDebuggerPlugin 提供了与调试器的编辑器端相关的函数。

要与调试器交互,必须将这个类的实例通过 EditorPlugin.add_debugger_plugin 添加至编辑器。

添加完成后,会针对该插件可用的每一个编辑器调试器会话 EditorDebuggerSession 回调一次 _setup_session,后续有新的会话也会进行回调(这些会话在此阶段可能尚未激活)。

你可以通过 get_sessions 获取所有可用的 EditorDebuggerSession,也可以通过 get_session 获取特定的会话。

GDScript

  1. @tool
  2. extends EditorPlugin
  3. class ExampleEditorDebugger extends EditorDebuggerPlugin:
  4. func _has_capture(prefix):
  5. # 如果想要处理带有这个前缀的消息则返回 true。
  6. return prefix == "my_plugin"
  7. func _capture(message, data, session_id):
  8. if message == "my_plugin:ping":
  9. get_session(session_id).send_message("my_plugin:echo", data)
  10. func _setup_session(session_id):
  11. # 在调试器会话 UI 中添加新的选项卡,其中包含一个标签。
  12. var label = Label.new()
  13. label.name = "Example plugin"
  14. label.text = "示例插件"
  15. var session = get_session(session_id)
  16. # 监听会话开始和停止信号。
  17. session.started.connect(func (): print("会话已开始"))
  18. session.stopped.connect(func (): print("会话已停止"))
  19. session.add_session_tab(label)
  20. var debugger = ExampleEditorDebugger.new()
  21. func _enter_tree():
  22. add_debugger_plugin(debugger)
  23. func _exit_tree():
  24. remove_debugger_plugin(debugger)

方法

bool

_capture ( String message, Array data, int session_id ) virtual

bool

_has_capture ( String capture ) virtual const

void

_setup_session ( int session_id ) virtual

EditorDebuggerSession

get_session ( int id )

Array

get_sessions ( )


方法说明

bool _capture ( String message, Array data, int session_id ) virtual

覆盖此方法以处理传入的消息。session_id 是接收到消息的 EditorDebuggerSession 的 ID(你可以通过 get_session 检索到它)。


bool _has_capture ( String capture ) virtual const

覆盖此方法以启用从调试器接收消息。如果capture是”my_message”,那么以”my_message:”开头的消息将会传递到_capture方法。


void _setup_session ( int session_id ) virtual

覆盖此方法,以在创建新的EditorDebuggerSession时被通知(此阶段期间可能处于非活动状态)。


EditorDebuggerSession get_session ( int id )

返回具有给定 idEditorDebuggerSession


Array get_sessions ( )

返回该调试器插件当前可用的 EditorDebuggerSession 数组。

注意:数组中的会话可能处于非活动状态,请通过 EditorDebuggerSession.is_active 检查它们的状态。

Previous Next


© 版权所有 2014-present Juan Linietsky, Ariel Manzur and the Godot community (CC BY 3.0). Revision b1c660f7.

Built with Sphinx using a theme provided by Read the Docs.