1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-19 14:31:59 +00:00

Merge pull request #72336 from TokageItLab/dupe-animation-name

Tweak the name for duplicated animations in the editor
This commit is contained in:
Rémi Verschelde
2023-01-30 10:02:20 +01:00

View File

@@ -1105,9 +1105,24 @@ void AnimationPlayerEditor::_animation_duplicate() {
return; return;
} }
int count = 2;
String new_name = current; String new_name = current;
while (player->has_animation(new_name)) { PackedStringArray split = new_name.split("_");
new_name = new_name + " (copy)"; int last_index = split.size() - 1;
if (last_index > 0 && split[last_index].is_valid_int() && split[last_index].to_int() >= 0) {
count = split[last_index].to_int();
split.remove_at(last_index);
new_name = String("_").join(split);
}
while (true) {
String attempt = new_name;
attempt += vformat("_%d", count);
if (player->has_animation(attempt)) {
count++;
continue;
}
new_name = attempt;
break;
} }
if (new_name.contains("/")) { if (new_name.contains("/")) {