| 196 | } |
| 197 | |
| 198 | void Script::reload_from_file() { |
| 199 | #ifdef TOOLS_ENABLED |
| 200 | // Replicates how the ScriptEditor reloads script resources, which generally handles it. |
| 201 | // However, when scripts are to be reloaded but aren't open in the internal editor, we go through here instead. |
| 202 | const Ref<Script> rel = ResourceLoader::load(ResourceLoader::path_remap(get_path()), get_class(), ResourceFormatLoader::CACHE_MODE_IGNORE); |
| 203 | if (rel.is_null()) { |
| 204 | return; |
| 205 | } |
| 206 | |
| 207 | set_source_code(rel->get_source_code()); |
| 208 | set_last_modified_time(rel->get_last_modified_time()); |
| 209 | |
| 210 | // Only reload the script when there are no compilation errors to prevent printing the error messages twice. |
| 211 | if (rel->is_valid()) { |
| 212 | if (Engine::get_singleton()->is_editor_hint() && is_tool()) { |
| 213 | get_language()->reload_tool_script(this, true); |
| 214 | } else { |
| 215 | // It's important to set p_keep_state to true in order to manage reloading scripts |
| 216 | // that are currently instantiated. |
| 217 | reload(true); |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | #else |
| 222 | Resource::reload_from_file(); |
| 223 | #endif |
| 224 | } |
| 225 | |
| 226 | void ScriptServer::set_scripting_enabled(bool p_enabled) { |
| 227 | scripting_enabled = p_enabled; |
nothing calls this directly
no test coverage detected