Implement Autostart Feature for Profiler / Visual Profiler / Network Profiler
Co-authored-by: stmSi <stm1998sithumyo@gmail.com>
This commit is contained in:
@ -148,8 +148,8 @@ void EditorVisualProfiler::_item_selected() {
|
||||
}
|
||||
|
||||
void EditorVisualProfiler::_update_plot() {
|
||||
const int w = graph->get_size().width;
|
||||
const int h = graph->get_size().height;
|
||||
const int w = graph->get_size().width + 1; // `+1` is to prevent from crashing when visual profiler is auto started.
|
||||
const int h = graph->get_size().height + 1;
|
||||
|
||||
bool reset_texture = false;
|
||||
|
||||
@ -427,6 +427,10 @@ void EditorVisualProfiler::_clear_pressed() {
|
||||
_update_plot();
|
||||
}
|
||||
|
||||
void EditorVisualProfiler::_autostart_toggled(bool p_toggled_on) {
|
||||
EditorSettings::get_singleton()->set_project_metadata("debug_options", "autostart_visual_profiler", p_toggled_on);
|
||||
}
|
||||
|
||||
void EditorVisualProfiler::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_ENTER_TREE:
|
||||
@ -668,9 +672,10 @@ void EditorVisualProfiler::set_enabled(bool p_enable) {
|
||||
activate->set_disabled(!p_enable);
|
||||
}
|
||||
|
||||
void EditorVisualProfiler::set_pressed(bool p_pressed) {
|
||||
activate->set_pressed(p_pressed);
|
||||
void EditorVisualProfiler::set_profiling(bool p_profiling) {
|
||||
activate->set_pressed(p_profiling);
|
||||
_update_button_text();
|
||||
emit_signal(SNAME("enable_profiling"), activate->is_pressed());
|
||||
}
|
||||
|
||||
bool EditorVisualProfiler::is_profiling() {
|
||||
@ -747,6 +752,12 @@ EditorVisualProfiler::EditorVisualProfiler() {
|
||||
clear_button->connect(SceneStringName(pressed), callable_mp(this, &EditorVisualProfiler::_clear_pressed));
|
||||
hb->add_child(clear_button);
|
||||
|
||||
CheckBox *autostart_checkbox = memnew(CheckBox);
|
||||
autostart_checkbox->set_text(TTR("Autostart"));
|
||||
autostart_checkbox->set_pressed(EditorSettings::get_singleton()->get_project_metadata("debug_options", "autostart_visual_profiler", false));
|
||||
autostart_checkbox->connect(SceneStringName(toggled), callable_mp(this, &EditorVisualProfiler::_autostart_toggled));
|
||||
hb->add_child(autostart_checkbox);
|
||||
|
||||
hb->add_child(memnew(Label(TTR("Measure:"))));
|
||||
|
||||
display_mode = memnew(OptionButton);
|
||||
|
||||
Reference in New Issue
Block a user