Godot Version
v4.6.2.stable.official [71f334935]
Question
Okay I’m stumped again with plugins. Hopefully someone might be able to point out my rookie mistake. Why do I always get a null value when calling
.get_base_editor()
It seems as though the script_editor is not getting set and is always null. My parent code for creating the dock with the UI dock works, (at the bottom), I just can’t seen to get the CodeEdit object bit right.
@tool
extends Control
class_name bookmark_browser
@onready var item_list: ItemList = $ItemList
@onready var script_editor: ScriptEditor = EditorInterface.get_script_editor()
@onready var code_editor: CodeEdit
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
code_editor = script_editor.get_current_editor().get_base_editor()
code_editor.caret_changed.connect(script_edited)
func script_edited() -> void:
if code_editor:
print(code_editor.get_bookmarked_lines())
@tool
extends EditorPlugin
# Dock reference.
var dock: EditorDock
# Plugin initialization.
func _enter_tree() -> void:
dock = EditorDock.new()
dock.title = "Bookmarks"
dock.default_slot = EditorDock.DOCK_SLOT_RIGHT_UL
var dock_content: bookmark_browser = preload("./bookmarks_scene.tscn").instantiate()
dock.add_child(dock_content)
add_dock(dock)
# Plugin clean-up.
func _exit_tree() -> void:
remove_dock(dock)
dock.queue_free()
dock = null
