I want to have it so I can get my GUI and Word3D variables children with autocomplete.
I’ve only tried adding @tool at the top, but that doesn’t work.
Is it even possible to do this?
The Script in Question:
@tool
class_name GameRoot extends Node
#Refrences
@export_category("Refrences")
@onready var world3D:Node3D = %World3D
@onready var gui:Control = %GUI
@onready var HBox:HBoxContainer = $GUI/PanelContainer/HBoxContainer
#Guns
@onready var pistol := load("res://Scenes/Pistol.tscn")
@onready var ak := load("res://Scenes/AK.tscn")
#Player
const PLAYER := preload("res://Scenes/Player.tscn")
@onready var local_player:Player
func _init() -> void:
globals.game = self
func _ready() -> void:
if not Engine.is_editor_hint():
#Spawn the local player
local_player = PLAYER.instantiate() as Player
add_child(local_player)
If your GUI and World3D nodes have scripts on them with a class_name
you can define their type as that class name instead of base node types
@onready var world3D: World3DClassName = %World3D
@onready var gui : GuiClassName= %GUI
If they do not then you could preload the scripts as a type
const World3DClassScript = preload("res://world_3d_class_script.gd")
@onready var world3D: World3DClassScript = %World3D
1 Like
Oh sorry, I didn’t mention how those were Node3D and Control, without any scripts attached to them.
I usually use them and get_node() my way into finding one of their children, but this feels dangerous and I’m not sure if there is a way to add autocomplete to them.
If your answer already answered my question, please specify more accurately how I can achieve this, otherwise my bad for not mentioning that in the post
You will have to use get_node
to get their children, or %GUI/ChildName
. Autocomplete for children nodes is a best-attempt system, no reason scripts should understand the scene heirarchy on their own.
1 Like