rokojori_action_library/plugin.gd

42 lines
922 B
GDScript

@tool
extends EditorPlugin
const RokojoriPluginScript = preload( "res://addons/rokojori_action_library/RokojoriPlugin.cs" )
const NodeContextMenuScript = preload( "res://addons/rokojori_action_library/Tools/Editor/RJ_NodeContextMenu.gd" )
var csPlugin
var nodeContextMenu
func _ensure_cs_plugin() -> void:
if csPlugin == null:
csPlugin = RokojoriPluginScript.new()
add_child( csPlugin )
func _enter_tree() -> void:
_ensure_cs_plugin()
nodeContextMenu = NodeContextMenuScript.new()
add_context_menu_plugin( EditorContextMenuPlugin.CONTEXT_SLOT_SCENE_TREE, nodeContextMenu )
func _exit_tree() -> void:
if nodeContextMenu:
remove_context_menu_plugin( nodeContextMenu )
nodeContextMenu = null
if csPlugin:
csPlugin.queue_free()
csPlugin = null
func _enable_plugin() -> void:
_ensure_cs_plugin()
csPlugin.EnablePlugin()
func _disable_plugin() -> void:
if csPlugin:
csPlugin.DisablePlugin()