Skip to content

Commit

Permalink
Experimental code change
Browse files Browse the repository at this point in the history
  • Loading branch information
RevoluPowered committed Jul 5, 2024
1 parent 1f989af commit b56187b
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion mirror-godot-app/ui/game/game_ui_static.gd
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,30 @@ static func ui_ready() -> void:


static var _last_state: bool = false
static var lockout = false
static func set_vr_mouse_state(state: bool) -> void:
if lockout:
return
lockout = true
if _sub_viewport == null or state == _last_state:
return # this is non VR mode and is okay to ignore this setting then
print("VR GameUI status changed: ", state)
_last_state = state
_vr_controller_menu.set_vr_mouse_input_state(state)
await _root_node.get_tree().create_timer(45.0).timeout
_last_state = false
_vr_controller_menu.set_vr_mouse_input_state(false)
print("Removing menu")
# remove VRControllerMenu node (not required)
_root_node.remove_child(_vr_controller_menu)
_vr_controller_menu.queue_free()

print("Removing subviewport")
# remove subviewport
_sub_viewport.remove_child(_internal_instance)
_root_node.add_child(_internal_instance)
_sub_viewport.get_parent().remove_child(_sub_viewport)
_sub_viewport.queue_free()


## Called when booting the app when we know if the app is VR or non-VR
Expand All @@ -65,7 +83,7 @@ static func setup_game_ui(root_node: Node, is_vr: bool):
if is_vr:
## Add the player controller for the menu
var vr_player_for_menu: VRControllerMenu = _readonly_vr_menu.instantiate()
root_node.add_child.call_deferred(vr_player_for_menu)
root_node.add_child(vr_player_for_menu)
## Add the subviewport for the VR Headset's UI
_sub_viewport = SubViewport.new()
_sub_viewport.render_target_update_mode = SubViewport.UPDATE_ALWAYS
Expand Down

0 comments on commit b56187b

Please sign in to comment.