29 lines
855 B
GDScript
29 lines
855 B
GDScript
extends Node3D
|
|
|
|
var xr_interface: XRInterface
|
|
|
|
func _ready():
|
|
xr_interface = XRServer.find_interface("OpenXR")
|
|
if xr_interface and xr_interface.is_initialized():
|
|
print("OpenXR initialized successfully")
|
|
|
|
# Turn off v-sync!
|
|
DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_DISABLED)
|
|
|
|
# Change our main viewport to output to the HMD
|
|
get_viewport().use_xr = true
|
|
else:
|
|
print("OpenXR not initialized, please check if your headset is connected")
|
|
_initialize_xr_tools()
|
|
|
|
func _initialize_xr_tools():
|
|
if Engine.has_singleton("XRTools"):
|
|
var xrtools = Engine.get_singleton("XRTools")
|
|
if xrtools.has_method("initialize"):
|
|
xrtools.initialize()
|
|
print("🧩 XR Tools initialisiert!")
|
|
else:
|
|
print("⚠️ XRTools.initialize() Methode nicht gefunden.")
|
|
else:
|
|
print("⚠️ XRTools wurde noch nicht als Singleton registriert.")
|