node25d_plugin.gd 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. @tool
  2. extends EditorPlugin
  3. const MainPanel = preload("res://addons/node25d/main_screen/main_screen_25d.tscn")
  4. var main_panel_instance: VBoxContainer
  5. func _enter_tree() -> void:
  6. main_panel_instance = MainPanel.instantiate()
  7. main_panel_instance.get_child(1).editor_interface = get_editor_interface()
  8. # Add the main panel to the editor's main viewport.
  9. EditorInterface.get_editor_main_screen().add_child(main_panel_instance)
  10. # Hide the main panel.
  11. _make_visible(false)
  12. # When this plugin node enters tree, add the custom types.
  13. add_custom_type("Node25D", "Node2D", preload("node_25d.gd"), preload("icons/node_25d_icon.png"))
  14. add_custom_type("YSort25D", "Node", preload("y_sort_25d.gd"), preload("icons/y_sort_25d_icon.png"))
  15. add_custom_type("ShadowMath25D", "CharacterBody3D", preload("shadow_math_25d.gd"), preload("icons/shadow_math_25d_icon.png"))
  16. func _exit_tree() -> void:
  17. if main_panel_instance:
  18. main_panel_instance.queue_free()
  19. # When the plugin node exits the tree, remove the custom types.
  20. remove_custom_type("ShadowMath25D")
  21. remove_custom_type("YSort25D")
  22. remove_custom_type("Node25D")
  23. func _has_main_screen() -> bool:
  24. return true
  25. func _make_visible(visible: bool) -> void:
  26. if main_panel_instance:
  27. if visible:
  28. main_panel_instance.show()
  29. else:
  30. main_panel_instance.hide()
  31. func _get_plugin_name() -> String:
  32. return "2.5D"
  33. func _get_plugin_icon() -> Texture2D:
  34. return preload("res://addons/node25d/icons/viewport_25d.svg")
  35. func _handles(obj: Object) -> bool:
  36. return obj is Node25D