-
-
Save belzecue/832667f0efa764c9b4e710c8b2259321 to your computer and use it in GitHub Desktop.
Revisions
-
gruebite revised this gist
Jul 27, 2025 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,7 +13,7 @@ static func scene(clss_name: Variant) -> Node: static func scene_path(clss_name: Variant) -> String: var clss_path := (clss_name as Resource).resource_path assert(clss_path.ends_with(".gd"), "missing script for class") var scn_path := clss_path.substr(0, clss_path.rfind(".gd")) + ".tscn" assert(ResourceLoader.exists(scn_path), "missing scene for class") return scn_path -
gruebite revised this gist
Jul 27, 2025 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,5 +3,5 @@ extends Node func _ready() -> void: # MyScene is is a `class_name` in a `.gd` script with an associated `.tscn` file var scene = Instantiate.scene(MyScene) add_child(scene) -
gruebite revised this gist
Jul 27, 2025 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,6 +2,6 @@ extends Node func _ready() -> void: # MyScene is is a `class_name` in a `.gd` script with an associated `.tscn` file var scene = MyScene.instantiate() add_child(scene) -
gruebite revised this gist
Jul 27, 2025 . No changes.There are no files selected for viewing
-
gruebite revised this gist
Jul 27, 2025 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,4 +4,4 @@ extends Node func _ready() -> void: # MyScene is is a `class_name` in a `.gd` script with an associated `.tscn` file var scene = MyScene.instantiate() add_child(scene) -
gruebite revised this gist
Jul 27, 2025 . 1 changed file with 7 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ extends Node func _ready() -> void: # MyScene is is a `class_name` in a `.gd` script with an associated `.tscn` file var scene = MyScene.instantiate() add_child(scene) -
gruebite created this gist
Jul 27, 2025 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ class_name Instantiate extends Object ## Instantiates a scene based on [param clss_name]. Scene must be located next ## to the associated class. static func scene(clss_name: Variant) -> Node: var scn_path := scene_path(clss_name) var scn: PackedScene = ResourceLoader.load(scn_path) var node := scn.instantiate() return node static func scene_path(clss_name: Variant) -> String: var clss_path := (clss_name as Resource).resource_path assert(clss_path.ends_with(".gd"), "can't instantiate non-class") var scn_path := clss_path.substr(0, clss_path.rfind(".gd")) + ".tscn" assert(ResourceLoader.exists(scn_path), "can't find scene from class") return scn_path