Auto-increment frame_coords when keying
This commit is contained in:
parent
365558b8b7
commit
6c0ef9f729
3 changed files with 21 additions and 1 deletions
|
@ -644,7 +644,19 @@ void EditorProperty::_gui_input(const Ref<InputEvent> &p_event) {
|
|||
emit_signal("property_keyed", property, use_keying_next());
|
||||
|
||||
if (use_keying_next()) {
|
||||
if (property == "frame_coords" && (object->is_class("Sprite") || object->is_class("Sprite3D"))) {
|
||||
Vector2 new_coords = object->get(property);
|
||||
new_coords.x++;
|
||||
if (new_coords.x >= object->get("hframes").operator int64_t()) {
|
||||
new_coords.x = 0;
|
||||
new_coords.y++;
|
||||
}
|
||||
|
||||
call_deferred("emit_changed", property, new_coords, "", false);
|
||||
} else {
|
||||
call_deferred("emit_changed", property, object->get(property).operator int64_t() + 1, "", false);
|
||||
}
|
||||
|
||||
call_deferred("update_property");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -387,6 +387,10 @@ void Sprite::_validate_property(PropertyInfo &property) const {
|
|||
property.hint_string = "0," + itos(vframes * hframes - 1) + ",1";
|
||||
property.usage |= PROPERTY_USAGE_KEYING_INCREMENTS;
|
||||
}
|
||||
|
||||
if (property.name == "frame_coords") {
|
||||
property.usage |= PROPERTY_USAGE_KEYING_INCREMENTS;
|
||||
}
|
||||
}
|
||||
|
||||
void Sprite::_texture_changed() {
|
||||
|
|
|
@ -662,6 +662,10 @@ void Sprite3D::_validate_property(PropertyInfo &property) const {
|
|||
property.hint_string = "0," + itos(vframes * hframes - 1) + ",1";
|
||||
property.usage |= PROPERTY_USAGE_KEYING_INCREMENTS;
|
||||
}
|
||||
|
||||
if (property.name == "frame_coords") {
|
||||
property.usage |= PROPERTY_USAGE_KEYING_INCREMENTS;
|
||||
}
|
||||
}
|
||||
|
||||
void Sprite3D::_bind_methods() {
|
||||
|
|
Loading…
Reference in a new issue