Auto-select sole AnimationPlayer on panel open
This commit is contained in:
parent
8a741f10f8
commit
cf65c18817
2 changed files with 22 additions and 0 deletions
|
|
@ -56,6 +56,24 @@
|
|||
|
||||
///////////////////////////////////
|
||||
|
||||
void AnimationPlayerEditor::_find_player() {
|
||||
if (!is_visible() || player) {
|
||||
return;
|
||||
}
|
||||
|
||||
Node *edited_scene = EditorNode::get_singleton()->get_edited_scene();
|
||||
|
||||
if (!edited_scene) {
|
||||
return;
|
||||
}
|
||||
|
||||
TypedArray<Node> players = edited_scene->find_children("", "AnimationPlayer");
|
||||
|
||||
if (players.size() == 1) {
|
||||
plugin->edit(players.front());
|
||||
}
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_node_removed(Node *p_node) {
|
||||
if (player && original_node == p_node) {
|
||||
if (is_dummy) {
|
||||
|
|
@ -130,6 +148,8 @@ void AnimationPlayerEditor::_notification(int p_what) {
|
|||
|
||||
get_tree()->connect(SNAME("node_removed"), callable_mp(this, &AnimationPlayerEditor::_node_removed));
|
||||
|
||||
EditorNode::get_singleton()->connect("scene_changed", callable_mp(this, &AnimationPlayerEditor::_find_player));
|
||||
|
||||
add_theme_style_override(SceneStringName(panel), EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SceneStringName(panel), SNAME("Panel")));
|
||||
} break;
|
||||
|
||||
|
|
@ -190,6 +210,7 @@ void AnimationPlayerEditor::_notification(int p_what) {
|
|||
} break;
|
||||
|
||||
case NOTIFICATION_VISIBILITY_CHANGED: {
|
||||
_find_player();
|
||||
_ensure_dummy_player();
|
||||
} break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -249,6 +249,7 @@ class AnimationPlayerEditor : public VBoxContainer {
|
|||
protected:
|
||||
void _notification(int p_what);
|
||||
void _node_removed(Node *p_node);
|
||||
void _find_player();
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue