Godot Version
Godot 4.3-stable_win64
Question
While writing an editor plugin, I mentioned that my edited resource continue hanging somewhere and not going to be free.
Going deeper, I excluded my editor plugin widget as a potentional reason of resource hanging and wrote the next simple code in my plugin.gd:
@tool
extends EditorPlugin
var _inspector: EditorInspector = null
func _enter_tree() -> void:
_inspector = get_editor_interface().get_inspector()
_inspector.edited_object_changed.connect(_on_edited_object_changed)
_on_edited_object_changed()
func _exit_tree() -> void:
_inspector.edited_object_changed.disconnect(_on_edited_object_changed)
_inspector = null
func _on_edited_object_changed():
var _object = _inspector.get_edited_object()
if _object is Resource:
print("Object ref count = ", _object.get_reference_count())
Switching between any resource increase its reference count by some value (1 more often, but sometimes 2 and more).
Maybe editor caches resources for some purpose. Does anyone know the reason of such behaviour? And is it normal?