main_screen_plugin.gd 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. @tool
  2. extends EditorPlugin
  3. const MainPanel = preload("res://addons/main_screen/main_panel.tscn")
  4. var main_panel_instance: CenterContainer
  5. func _enter_tree() -> void:
  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() -> void:
  12. if main_panel_instance:
  13. main_panel_instance.queue_free()
  14. func _has_main_screen() -> bool:
  15. return true
  16. func _make_visible(visible: bool) -> void:
  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: Object) -> bool:
  21. return is_instance_of(object, preload("res://addons/main_screen/handled_by_main_screen.gd"))
  22. func _get_plugin_name() -> String:
  23. return "Main Screen Plugin"
  24. func _get_plugin_icon() -> Texture2D:
  25. return get_editor_interface().get_base_control().get_theme_icon("Node", "EditorIcons")