node25d_plugin.gd 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. @tool
  2. extends EditorPlugin
  3. const MainPanel = preload("res://addons/node25d/main_screen/main_screen_25d.tscn")
  4. var main_panel_instance
  5. func _enter_tree():
  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. get_editor_interface().get_editor_viewport().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():
  17. main_panel_instance.queue_free()
  18. # When the plugin node exits the tree, remove the custom types.
  19. remove_custom_type("ShadowMath25D")
  20. remove_custom_type("YSort25D")
  21. remove_custom_type("Node25D")
  22. func has_main_screen():
  23. return true
  24. func make_visible(visible):
  25. if visible:
  26. main_panel_instance.show()
  27. else:
  28. main_panel_instance.hide()
  29. func get_plugin_name():
  30. return "2.5D"
  31. func get_plugin_icon():
  32. return preload("res://addons/node25d/icons/viewport_25d.svg")