diff --git a/doc/classes/EditorSettings.xml b/doc/classes/EditorSettings.xml
index 3900a81502c..4a6fcd4c64b 100644
--- a/doc/classes/EditorSettings.xml
+++ b/doc/classes/EditorSettings.xml
@@ -520,6 +520,12 @@
If [code]true[/code], create a [code]RESET[/code] track when creating a new animation track. This track can be used to restore the animation to a "default" state.
+
+ Controls whether [AnimationPlayer] will apply snapping to nearest integer FPS when snapping is in Seconds mode. The option is remembered locally for a scene and this option only determines the default value when scene doesn't have local state yet.
+
+
+ Default step mode for [AnimationPlayer] (seconds or FPS). The option is remembered locally for a scene and this option only determines the default value when scene doesn't have local state yet.
+
The modulate color to use for "future" frames displayed in the animation editor's onion skinning feature.
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp
index dbb23d6f17a..de68544e1b6 100644
--- a/editor/animation_track_editor.cpp
+++ b/editor/animation_track_editor.cpp
@@ -3894,6 +3894,7 @@ bool AnimationTrackEditor::has_keying() const {
Dictionary AnimationTrackEditor::get_state() const {
Dictionary state;
state["fps_mode"] = timeline->is_using_fps();
+ state["fps_compat"] = fps_compat->is_pressed();
state["zoom"] = zoom->get_value();
state["offset"] = timeline->get_value();
state["v_scroll"] = scroll->get_v_scroll_bar()->get_value();
@@ -3909,27 +3910,34 @@ void AnimationTrackEditor::set_state(const Dictionary &p_state) {
snap_mode->select(0);
}
_snap_mode_changed(snap_mode->get_selected());
- } else {
- snap_mode->select(0);
- _snap_mode_changed(snap_mode->get_selected());
}
+
+ if (p_state.has("fps_compat")) {
+ fps_compat->set_pressed(p_state["fps_compat"]);
+ }
+
if (p_state.has("zoom")) {
zoom->set_value(p_state["zoom"]);
- } else {
- zoom->set_value(1.0);
}
+
if (p_state.has("offset")) {
timeline->set_value(p_state["offset"]);
- } else {
- timeline->set_value(0);
}
+
if (p_state.has("v_scroll")) {
scroll->get_v_scroll_bar()->set_value(p_state["v_scroll"]);
- } else {
- scroll->get_v_scroll_bar()->set_value(0);
}
}
+void AnimationTrackEditor::clear() {
+ snap_mode->select(EDITOR_GET("editors/animation/default_fps_mode"));
+ _snap_mode_changed(snap_mode->get_selected());
+ fps_compat->set_pressed(EDITOR_GET("editors/animation/default_fps_compatibility"));
+ zoom->set_value(1.0);
+ timeline->set_value(0);
+ scroll->get_v_scroll_bar()->set_value(0);
+}
+
void AnimationTrackEditor::cleanup() {
set_animation(Ref(), read_only);
}
@@ -7704,9 +7712,9 @@ AnimationTrackEditor::AnimationTrackEditor() {
snap_mode = memnew(OptionButton);
snap_mode->add_item(TTR("Seconds"));
snap_mode->add_item(TTR("FPS"));
+ snap_mode->set_disabled(true);
bottom_hf->add_child(snap_mode);
snap_mode->connect(SceneStringName(item_selected), callable_mp(this, &AnimationTrackEditor::_snap_mode_changed));
- snap_mode->set_disabled(true);
bottom_hf->add_child(memnew(VSeparator));
diff --git a/editor/animation_track_editor.h b/editor/animation_track_editor.h
index 5d998aed66f..3f39172eabe 100644
--- a/editor/animation_track_editor.h
+++ b/editor/animation_track_editor.h
@@ -916,6 +916,7 @@ public:
Dictionary get_state() const;
void set_state(const Dictionary &p_state);
+ void clear();
void cleanup();
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 9a5a51a18a2..8112777349c 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -899,6 +899,8 @@ void EditorSettings::_load_defaults(Ref p_extra_config) {
EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "editors/polygon_editor/auto_bake_delay", 1.5, "-1.0,10.0,0.01");
// Animation
+ EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "editors/animation/default_fps_mode", 0, "Seconds,FPS");
+ _initial_set("editors/animation/default_fps_compatibility", true);
_initial_set("editors/animation/autorename_animation_tracks", true);
_initial_set("editors/animation/confirm_insert_track", true, true);
_initial_set("editors/animation/default_create_bezier_tracks", false, true);
diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp
index e00c7526a19..4859c3ba65c 100644
--- a/editor/plugins/animation_player_editor_plugin.cpp
+++ b/editor/plugins/animation_player_editor_plugin.cpp
@@ -923,6 +923,10 @@ void AnimationPlayerEditor::set_state(const Dictionary &p_state) {
}
}
+void AnimationPlayerEditor::clear() {
+ track_editor->clear();
+}
+
void AnimationPlayerEditor::_animation_resource_edit() {
String current = _get_current();
if (current != String()) {
diff --git a/editor/plugins/animation_player_editor_plugin.h b/editor/plugins/animation_player_editor_plugin.h
index 5295934dfcb..f9f68ac96d7 100644
--- a/editor/plugins/animation_player_editor_plugin.h
+++ b/editor/plugins/animation_player_editor_plugin.h
@@ -266,6 +266,7 @@ public:
AnimationTrackEditor *get_track_editor() { return track_editor; }
Dictionary get_state() const;
void set_state(const Dictionary &p_state);
+ void clear();
void ensure_visibility();
@@ -298,6 +299,7 @@ protected:
public:
virtual Dictionary get_state() const override { return anim_editor->get_state(); }
virtual void set_state(const Dictionary &p_state) override { anim_editor->set_state(p_state); }
+ virtual void clear() override { anim_editor->clear(); }
virtual String get_plugin_name() const override { return "Anim"; }
bool has_main_screen() const override { return false; }