diff --git a/Spatial.tscn b/Spatial.tscn index e9e756f..4823d84 100644 --- a/Spatial.tscn +++ b/Spatial.tscn @@ -6,7 +6,7 @@ [ext_resource type="PackedScene" uid="uid://fiul51tsyoop" path="res://addons/godot-xr-tools/functions/function_teleport.tscn" id="3_isyx6"] [ext_resource type="PackedScene" uid="uid://diyu06cw06syv" path="res://addons/godot-xr-tools/player/player_body.tscn" id="3_m4pts"] [ext_resource type="PackedScene" uid="uid://c8l60rnugru40" path="res://addons/godot-xr-tools/objects/pickable.tscn" id="5_r3xxt"] -[ext_resource type="PackedScene" path="res://addons/xr-simulator/XRSimulator.tscn" id="7_yovyb"] +[ext_resource type="PackedScene" uid="uid://ctltchlf2j2r4" path="res://addons/xr-simulator/XRSimulator.tscn" id="7_yovyb"] [ext_resource type="PackedScene" uid="uid://clc5dre31iskm" path="res://addons/godot-xr-tools/xr/start_xr.tscn" id="8_qoqsw"] [sub_resource type="BoxShape3D" id="1"] @@ -117,7 +117,6 @@ transform = Transform3D(0.402254, -0.874811, 0.269994, -0.530985, 0.0173175, 0.8 shadow_enabled = true [node name="XRSimulator" parent="." instance=ExtResource("7_yovyb")] -is_camera_y_limited = false xr_origin = NodePath("../XROrigin3D") [node name="StartXR" parent="." instance=ExtResource("8_qoqsw")] diff --git a/addons/xr-simulator/XRSimulator.gd b/addons/xr-simulator/XRSimulator.gd index 7387cab..b40e5e3 100644 --- a/addons/xr-simulator/XRSimulator.gd +++ b/addons/xr-simulator/XRSimulator.gd @@ -1,6 +1,7 @@ extends Node @export var enabled: bool +@export var disable_xr_in_editor: bool = true @export var device_x_sensitivity: float = 1 @export var device_y_sensitivity: float = 1 @export var scroll_sensitivity: float = 1 @@ -33,6 +34,8 @@ var key_map = { KEY_ENTER: "menu_button" } +@onready var viewport: Viewport = get_viewport() + func _ready(): if not enabled or \ XRServer.get_tracker("left_hand") or \ @@ -68,13 +71,15 @@ func _ready(): XRServer.add_tracker(right_tracker) +func _process(_delta): + if enabled and disable_xr_in_editor and OS.has_feature("editor") and viewport.use_xr: + viewport.use_xr = false + func _input(event): if not enabled: return if Input.is_key_pressed(KEY_ESCAPE): Input.mouse_mode = Input.MOUSE_MODE_VISIBLE - elif Input.is_key_pressed(KEY_F11): - get_viewport().use_xr = !get_viewport().use_xr elif Input.mouse_mode != Input.MOUSE_MODE_CAPTURED and event is InputEventMouseButton: Input.mouse_mode = Input.MOUSE_MODE_CAPTURED