immersive-home/app/lib/globals/console.gd

29 lines
707 B
GDScript3
Raw Normal View History

2024-03-21 11:51:28 +02:00
extends Node
const console_scene = preload ("res://content/ui/console.tscn")
var _console: Node3D = null
2024-04-11 17:51:30 +03:00
@onready var main = get_node_or_null("/root/Main")
2024-03-21 11:51:28 +02:00
func _ready():
2024-04-11 17:51:30 +03:00
if main == null:
return
main.tree_entered.connect(func():
2024-03-21 11:51:28 +02:00
init_console()
)
func init_console():
_console = console_scene.instantiate()
2024-04-11 17:51:30 +03:00
main.add_child(_console)
2024-03-21 11:51:28 +02:00
var camera = get_node("/root/Main/XROrigin3D/XRCamera3D")
_console.global_position = camera.global_position + camera.global_transform.basis.z * - 1
_console.global_transform.basis = Basis.looking_at(_console.global_position - camera.global_position)
func log(message):
print(message, _console)
if _console == null:
init_console()
_console.log(message)