MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / reload_from_file

Method reload_from_file

core/object/script_language.cpp:198–224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

196}
197
198void 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
226void ScriptServer::set_scripting_enabled(bool p_enabled) {
227 scripting_enabled = p_enabled;

Callers

nothing calls this directly

Calls 7

get_languageFunction · 0.85
is_nullMethod · 0.45
get_source_codeMethod · 0.45
is_validMethod · 0.45
is_editor_hintMethod · 0.45
reload_tool_scriptMethod · 0.45

Tested by

no test coverage detected