-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a runtime selection dropdown into the editor
- Loading branch information
1 parent
874372c
commit a7ce6b8
Showing
9 changed files
with
124 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[gd_resource type="NativeScript" load_steps=2 format=2] | ||
|
||
[ext_resource path="res://addons/godot-openxr/godot_openxr.gdnlib" type="GDNativeLibrary" id=1] | ||
|
||
[resource] | ||
resource_name = "OpenXRRuntimeSelect" | ||
class_name = "OpenXRRuntimeSelect" | ||
library = ExtResource( 1 ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
tool | ||
extends OptionButton | ||
|
||
var available_runtimes : Array = Array() | ||
onready var platform = OS.get_name() | ||
|
||
# Called when the node enters the scene tree for the first time. | ||
func _ready(): | ||
var current_runtime = 0 | ||
|
||
# read our json file, may have entries for multiple platforms, we'll filter them later | ||
var f = File.new() | ||
if (f.open("res://addons/godot-openxr/runtimes.json", File.READ)) == OK: | ||
var json = JSON.parse(f.get_as_text()) | ||
available_runtimes = json.result as Array | ||
f.close() | ||
|
||
# check what our current value is | ||
var current_path = OS.get_environment("XR_RUNTIME_JSON") | ||
|
||
if available_runtimes.size() > 0: | ||
# reset our dropdown if applicable | ||
clear() | ||
add_item("Default", -1) | ||
|
||
# check which runtimes are actually available | ||
var dir = Directory.new() | ||
var index = 0 | ||
for i in available_runtimes.size(): | ||
var runtime = available_runtimes[i] | ||
if dir.file_exists(runtime["path"]): | ||
add_item(runtime["name"], i) | ||
index = index + 1 | ||
if available_runtimes[i]["path"] == current_path: | ||
current_runtime = index | ||
|
||
selected = current_runtime | ||
|
||
visible = true | ||
else: | ||
# I guess nothing supported on this platform | ||
visible = false | ||
|
||
func _on_OpenXRRunSelect_item_selected(index): | ||
# this need latest 3.2.4 | ||
if index == 0: | ||
print("Returning to default") | ||
OS.set_environment("XR_RUNTIME_JSON", "") | ||
else: | ||
var i = get_item_id(index) | ||
var runtime = available_runtimes[i]["path"] | ||
print("Switching to " + runtime) | ||
OS.set_environment("XR_RUNTIME_JSON", runtime) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[gd_scene load_steps=2 format=2] | ||
|
||
[ext_resource path="res://addons/godot-openxr/editor/OpenXRRunSelect.gd" type="Script" id=1] | ||
|
||
[node name="OpenXRRunSelect" type="OptionButton"] | ||
text = "Default" | ||
items = [ "Default", null, false, 9999, null, "SteamVR", null, false, 0, null, "Oculus", null, false, 1, null, "Microsoft MR", null, false, 2, null ] | ||
selected = 0 | ||
script = ExtResource( 1 ) | ||
__meta__ = { | ||
"_edit_use_anchors_": false | ||
} | ||
|
||
[connection signal="item_selected" from="." to="." method="_on_OpenXRRunSelect_item_selected"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[plugin] | ||
|
||
name="Godot OpenXR" | ||
description="Godot OpenXR plugin" | ||
author="Christoph Haagch and Bastiaan Olij" | ||
version="1.0.1" | ||
script="plugin.gd" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
tool | ||
extends EditorPlugin | ||
|
||
var openxr_run_select = null | ||
|
||
func _enter_tree(): | ||
# multiple runtimes are currently only supported on Windows | ||
openxr_run_select = preload("res://addons/godot-openxr/editor/OpenXRRunSelect.tscn").instance() | ||
add_control_to_container(CONTAINER_TOOLBAR, openxr_run_select) | ||
|
||
func _exit_tree(): | ||
if openxr_run_select: | ||
remove_control_from_container(EditorPlugin.CONTAINER_TOOLBAR, openxr_run_select) | ||
openxr_run_select.queue_free() | ||
openxr_run_select = null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[ | ||
{ | ||
"name": "Monado", | ||
"path": "/usr/share/openxr/1/openxr_monado.json" | ||
}, | ||
{ | ||
"name": "SteamVR", | ||
"path": "~/.steam/steam/steamapps/common/SteamVR/steamxr_linux64.json" | ||
}, | ||
{ | ||
"name": "SteamVR", | ||
"path": "C:\\Program Files (x86)\\Steam\\steamapps\\common\\SteamVR\\steamxr_win64.json" | ||
}, | ||
{ | ||
"name": "Oculus", | ||
"path": "C:\\Program Files\\Oculus\\Support\\oculus-runtime\\oculus_openxr_64.json" | ||
}, | ||
{ | ||
"name": "Microsoft MR", | ||
"path": "C:\\WINDOWS\\system32\\MixedRealityRuntime.json" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters