main_screen_plugin.gd 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. @tool
  2. extends EditorPlugin
  3. const MainPanel = preload("res://addons/main_screen/main_panel.tscn")
  4. var main_panel_instance
  5. func _enter_tree():
  6. main_panel_instance = MainPanel.instantiate()
  7. # Add the main panel to the editor's main viewport.
  8. get_editor_interface().get_editor_main_screen().add_child(main_panel_instance)
  9. # Hide the main panel. Very much required.
  10. _make_visible(false)
  11. func _exit_tree():
  12. if main_panel_instance:
  13. main_panel_instance.queue_free()
  14. func _has_main_screen():
  15. return true
  16. func _make_visible(visible):
  17. if main_panel_instance:
  18. main_panel_instance.visible = visible
  19. # If your plugin doesn't handle any node types, you can remove this method.
  20. func _handles(object):
  21. return is_instance_of(object, preload("res://addons/main_screen/handled_by_main_screen.gd"))
  22. func _get_plugin_name():
  23. return "Main Screen Plugin"
  24. func _get_plugin_icon():
  25. # Must return some kind of Texture2D for the icon.
  26. return get_editor_interface().get_base_control().get_theme_icon("Node", "EditorIcons")