GDScript: Allow trying to reload shallow script when instantiated
This commit is contained in:
parent
e4e024ab88
commit
1a5ec83fcc
3 changed files with 8 additions and 1 deletions
|
@ -205,8 +205,13 @@ GDScriptInstance *GDScript::_create_instance(const Variant **p_args, int p_argco
|
|||
Variant GDScript::_new(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
|
||||
/* STEP 1, CREATE */
|
||||
|
||||
if (!valid && shallow && !reloading && is_root_script()) {
|
||||
reload(true);
|
||||
}
|
||||
|
||||
if (!valid) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
|
||||
ERR_FAIL_COND_V_MSG(!valid, Variant(), "Can't instantiate invalid script.");
|
||||
r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL;
|
||||
return Variant();
|
||||
}
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@ class GDScript : public Script {
|
|||
bool tool = false;
|
||||
bool valid = false;
|
||||
bool reloading = false;
|
||||
bool shallow = true;
|
||||
|
||||
struct MemberInfo {
|
||||
int index = 0;
|
||||
|
|
|
@ -2645,6 +2645,7 @@ Error GDScriptCompiler::_prepare_compilation(GDScript *p_script, const GDScriptP
|
|||
|
||||
parsing_classes.insert(p_script);
|
||||
|
||||
p_script->shallow = false;
|
||||
p_script->clearing = true;
|
||||
|
||||
p_script->native = Ref<GDScriptNativeClass>();
|
||||
|
|
Loading…
Reference in a new issue