0 votes

How can I import the user's own scene into the game? So how can I import a non-imported scene file (.tscn) into the game with the help of "FileDialog"?

For the mod system in my game, I want to import the tscn file that the user wants, that is the scene file, to the game via "FileDialog". Is it possible?

Godot version v3.4.4.stable.official [419e713a2]
in Engine by (92 points)

2 Answers

0 votes
Best answer

Okay, this is actually very easy. For those who don't know, let me tell you;

--To change the scene:

    var user_scene_path = "user://test_scene.tscn"
    get_tree().change_scene(user_scene_path)

--To sample the scene:

    var user_scene_path = load("user://test_scene.tscn").instance()
    add_child(user_scene_path)

I hope I could help.

by (92 points)
0 votes

Look at ResourceLoader...

Something like:

var success = ProjectSettings.load_resource_pack( *path* ) )
var sceneToLoad = scene.get(*sceneName*, "")
if success && ResourceLoader.exists(sceneToLoad): *doSomething*
by (24 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.