Godot 3 to 4 rename
ARVRInterfaceGDNative in Godot 4: there is no such class
Godot 4 has no ARVRInterfaceGDNative and no class to rename it to. The converter's table maps it to Node3D, so the editor's error suggests Node3D, but an XR interface is not a node: XR plugins inherit XRInterfaceExtension now, and game code finds an interface through XRServer.
What Godot prints
A Godot 3 script that creates an ARVRInterfaceGDNative, the base class XR plugins used through GDNative.
extends Node
func _ready():
var xr = ARVRInterfaceGDNative.new()
print(xr.get_name())
SCRIPT ERROR: Parse Error: Identifier "ARVRInterfaceGDNative" not declared in the current scope. Did you mean to use "Node3D"?
at: GDScript::reload (res://answers/arvrinterfacegdnative-in-godot-4/repro.gd:4)
ERROR: Failed to load script "res://answers/arvrinterfacegdnative-in-godot-4/repro.gd" with error "Parse error".
at: load (modules/gdscript/gdscript_resource_format.cpp:46)The fix
Godot 4 code reaches XR interfaces through XRServer. get_interfaces() returns one Dictionary per interface, with its id and name; find_interface() returns the interface itself.
extends Node
func _ready() -> void:
for info in XRServer.get_interfaces():
print(info["id"], ": ", info["name"])
var openxr := XRServer.find_interface("OpenXR")
print("OpenXR interface: ", openxr.get_class() if openxr else "not found")
0: Native mobile
1: OpenXR
OpenXR interface: OpenXRInterfaceWhy it happens
In Godot 3.6, ARVRInterfaceGDNative was the GDNative wrapper for an ARVR interface: you instantiated it and set the GDNative library holding the interface.
GDScript's analyzer resolves every identifier when the script loads. ARVRInterfaceGDNative is not a class in Godot 4.7.2, so the script fails to parse and Godot does not load it. The editor build adds a name from Godot's 3 to 4 rename table, and this class's entry there is Node3D, so the error ends with Did you mean to use "Node3D"? Node3D is the base 3D scene node, not an XR interface.
An XR interface plugin for Godot 4 inherits XRInterfaceExtension, the base class the class reference names for XR interface extensions.
ARVRServer and ARVRInterface are XRServer and XRInterface. XRServer.get_interfaces() returns one Dictionary per interface with its id and name, so read info["name"]; find_interface() returns the XRInterface itself. In this headless run the list held Native mobile and OpenXR, and find_interface("OpenXR") returned an OpenXRInterface.
Sources
- renames_map_3_to_4.cpp line 1475, ARVRInterfaceGDNative to Node3D
- renames_map_3_to_4.cpp lines 1474 and 1478, ARVRInterface and ARVRServer
- gdscript_analyzer.cpp line 4687, the error with the rename hint
- XRInterfaceExtension class reference
- XRServer.find_interface and get_interfaces
- ARVRInterfaceGDNative at 3.6-stable
Run on Godot 4.7.2, .