You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-11 13:10:58 +00:00
Add default virtual gdscript:// path to GDScript instances
This commit is contained in:
@@ -1037,7 +1037,7 @@ String GDScript::get_script_path() const {
|
||||
}
|
||||
|
||||
Error GDScript::load_source_code(const String &p_path) {
|
||||
if (p_path.is_empty() || ResourceLoader::get_resource_type(p_path.get_slice("::", 0)) == "PackedScene") {
|
||||
if (p_path.is_empty() || p_path.begins_with("gdscript://") || ResourceLoader::get_resource_type(p_path.get_slice("::", 0)) == "PackedScene") {
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -1363,6 +1363,8 @@ GDScript::GDScript() :
|
||||
|
||||
GDScriptLanguage::get_singleton()->script_list.add(&script_list);
|
||||
}
|
||||
|
||||
path = vformat("gdscript://%d.gd", get_instance_id());
|
||||
}
|
||||
|
||||
void GDScript::_save_orphaned_subclasses(GDScript::ClearData *p_clear_data) {
|
||||
|
||||
20
modules/gdscript/tests/scripts/runtime/features/gdscript.gd
Normal file
20
modules/gdscript/tests/scripts/runtime/features/gdscript.gd
Normal file
@@ -0,0 +1,20 @@
|
||||
func test():
|
||||
var gdscr: = GDScript.new()
|
||||
gdscr.source_code = '''
|
||||
extends Resource
|
||||
|
||||
func test() -> void:
|
||||
prints("Outer")
|
||||
var inner = InnerClass.new()
|
||||
|
||||
class InnerClass:
|
||||
func _init() -> void:
|
||||
prints("Inner")
|
||||
'''
|
||||
@warning_ignore(return_value_discarded)
|
||||
gdscr.reload()
|
||||
|
||||
var inst = gdscr.new()
|
||||
|
||||
@warning_ignore(unsafe_method_access)
|
||||
inst.test()
|
||||
@@ -0,0 +1,3 @@
|
||||
GDTEST_OK
|
||||
Outer
|
||||
Inner
|
||||
Reference in New Issue
Block a user