Object in all scenes

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Eidam

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(;

:bust_in_silhouette: Reply From: IvanVoirol

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():

This will save my time!
A. H.

Eidam | 2020-08-30 10:52