0 votes

Hello,
please help! I have information window and I use this window on all scenes in my game.
Is possible make some scene, that will be displayed on all scenes, at the top. I don't want to add this window on every scene separately.
Thank you very much!
PS: Sorry for my bad english, I hope you understand that(;

in Engine by (265 points)

1 Answer

0 votes
Best answer

The easiest way I can think of, is to create an autoload script that loads the scene and put it as a child of the root node. Here are the steps :

  1. Create a new script called GlobalScene.gd :

extends Node


func load_global_scene():
var global_scene = ResourceLoader.load("path_to your_global_scene")

var global_scene_instance = global_scene.instance()
get_tree().get_root().add_child(global_scene_instance )
  1. Make it an autoload script, by going to Project > Project Settings > AutoLoad
    Then load the GlobalScene.gd script by clicking on the folder icon, and then clicking on the Add button. Your script can now be loaded from any scene in your project.
  2. Add the following line to the scripts of every scene you need to add your global scene into :
func _ready():
GlobalScene.load_global_scene()
by (188 points)
selected by

Thanks!
This will save my time!
A. H.

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.