On your EditorPlugin
implement handles
to return true
on any AnimationPlayer
given to it, and Godot should call edit
with the AnimationPlayer
that is to be edited currently.
Example code:
tool
extends EditorPlugin
var edited_animation_player:AnimationPlayer
func handles(object:Object) -> bool:
return object is AnimationPlayer
func edit(object:Object) -> void:
edited_animation_player = object
print(edited_animation_player)
I was hoping the information of which AnimationPlayer
is currently being edited in the Animation panel was perhaps stored in some node for the bottom panel?
Even if get the correct node from the interface:
var control:= Control.new()
var animation_player_editor:Control
add_control_to_bottom_panel(control, "puff")
for sibling in control.get_parent().get_children():
if (sibling as Control).get_class() == "AnimationPlayerEditor":
animation_player_editor = sibling
remove_control_from_bottom_panel(control)
if animation_player_editor != null:
print(animation_player_editor)
Which AnimationPlayer
it is editing is not exposed to scripting. We can find a get_player
method in the source code and a get_state
method also in the source code, but we could only access them from C++, as they are not bound for scripting (source code).
In theory we should be able to get the EditorPlugin
and call get_state
on it, however it is not working for me:
var animation_player_editor_plugin:EditorPlugin
for sibling in get_parent().get_children():
if (sibling as Node).get_class() == "AnimationPlayerEditorPlugin":
animation_player_editor_plugin = sibling
if animation_player_editor_plugin != null:
print(animation_player_editor_plugin.call("get_state"))
Despite get_state
being exposed on EditorPlugin
, it appears to not be possible to call it.
By the way, we can see in the source code for AnimationPlayerEditorPlugin
that it follows the handles
and edit
logic I used above.