Get which AnimationPlayer is currently shown in bottom panel Animation?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By CakeLover

I’m trying to create my own plugin and I need to figure out which AnimationPlayer node is currently shown in the bottom Animation panel

and please do not suggest I use get_selection() because even if I select multiple (or none ) AnimationPlayer node(s), only one is show on the Animation Panel

so far my approach has been to try finding the node to the Animation panel using get_editor_interface() and then maybe viewing it’s properties?

current animation .

Did I misunderstand the question?

ramazan | 2022-02-01 20:50

I’m sorry I don’t follow what do u mean by “current animation .”?

CakeLover | 2022-02-01 20:52

get_current_animation()

AnimationPlayer — Godot Engine (stable) documentation in English

ramazan | 2022-02-01 20:57

the docs haven’t specified how to use get_current_animation() could u explain?

CakeLover | 2022-02-01 21:04

print (current_animation)

Sorry, I’m not at the computer.

ramazan | 2022-02-01 21:07

how am I suppose to use that here?

tool
extends EditorPlugin

func _enter_tree():
	print(get_current_animation());

CakeLover | 2022-02-01 21:09

print (current_animation)
Delete get and “()”

ramazan | 2022-02-01 21:11

how is that suppose to work?
it’s a property you can’t just print it out without having the AnimationPlayer node itself

CakeLover | 2022-02-01 21:14

Sorry, I’m not at the computer.

ramazan | 2022-02-01 21:16

:bust_in_silhouette: Reply From: rossunger

Honestly, get_selection() is definitely the cleanest way I can think of to do this…

Like, in the handles() function, test if any of the selection is an AnimationPlayer and store that in a variable.
Then if you deselect the animationPlayer, you still have a reference to the last animationPlayer that was selected. And if you have more than 1 animation player selected then you will always have the last one selected in the variable.