node25d_plugin.gd 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. tool
  2. extends EditorPlugin
  3. const MainPanel = preload("res://addons/node25d-cs/main_screen/main_screen_25d.tscn")
  4. var main_panel_instance
  5. func _enter_tree():
  6. main_panel_instance = MainPanel.instance()
  7. #main_panel_instance.get_child(1).set("editorInterface", get_editor_interface()) # For C#
  8. main_panel_instance.get_child(1).editor_interface = get_editor_interface()
  9. # Add the main panel to the editor's main viewport.
  10. get_editor_interface().get_editor_viewport().add_child(main_panel_instance)
  11. # Hide the main panel.
  12. make_visible(false)
  13. # When this plugin node enters tree, add the custom types.
  14. add_custom_type("Node25D", "Node2D", preload("Node25D.cs"), preload("icons/node_25d_icon.png"))
  15. add_custom_type("YSort25D", "Node", preload("YSort25D.cs"), preload("icons/y_sort_25d_icon.png"))
  16. add_custom_type("ShadowMath25D", "KinematicBody", preload("ShadowMath25D.cs"), preload("icons/shadow_math_25d_icon.png"))
  17. func _exit_tree():
  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():
  24. return true
  25. func make_visible(visible):
  26. if visible:
  27. main_panel_instance.show()
  28. else:
  29. main_panel_instance.hide()
  30. func get_plugin_name():
  31. return "2.5D"
  32. func get_plugin_icon():
  33. return preload("res://addons/node25d-cs/icons/viewport_25d.svg")