1 using System.Collections;
2 using System.Collections.Generic;
8 using UnityEngine.XR.Management;
18 [InitializeOnLoadMethod]
20 [RuntimeInitializeOnLoadMethod]
23 AVR_DevConsole.register_command(
"echo", (s) =>
AVR_DevConsole.
print(
string.Join(
" ", s)), 1,
"Prints a given message back to the user.");
25 AVR_DevConsole.register_command(
"packages", (s) => print_packages(),
"Prints a list of all installed arc-vr packages");
27 AVR_DevConsole.register_command(
"clear", (s) =>
AVR_DevConsole.
clear(),
"Clears console output");
28 AVR_DevConsole.register_command(
"clr", (s) =>
AVR_DevConsole.
clear(),
"Clears console output");
30 AVR_DevConsole.register_command(
"toggle", (s) => toggle_obj(s), 1,
"Toggles a scene object with a given name.");
32 AVR_DevConsole.register_command(
"prefabs", (s) => prefabSearch(s), 2,
"Searches within the UnityEditor for prefabs. args[0] should be \"ui\" or \"props\" with the remainder being the search term.");
34 AVR_DevConsole.register_command(
"spam", (s) => {
for(
int i=0; i<100; i++)
AVR_DevConsole.
print(
"output"+i); },
"Outputs a bunch of console messages. Used for console testing/debugging.");
36 AVR_DevConsole.register_command(
"reconfigure", (s) => { AVR_Settings.reconfigure(); },
"Re-initializes AVR_Settings.");
40 AVR_DevConsole.register_command(
"set", (s) =>
AVR_Settings.
settings[s[0]]=s[1], 2,
"Sets a setting with settings-token arg[0] to the value of arg[1]");
44 AVR_DevConsole.register_command(
"stop_xr", (s) => StopXR());
49 Debug.Log(
"Initializing XR...");
50 yield
return XRGeneralSettings.Instance.Manager.InitializeLoader();
52 if (XRGeneralSettings.Instance.Manager.activeLoader == null)
54 Debug.LogError(
"Initializing XR Failed. Check Editor or Player log for details.");
58 Debug.Log(
"Starting XR...");
59 XRGeneralSettings.Instance.Manager.StartSubsystems();
65 Debug.Log(
"Stopping XR...");
67 XRGeneralSettings.Instance.Manager.StopSubsystems();
68 XRGeneralSettings.Instance.Manager.DeinitializeLoader();
69 Debug.Log(
"XR stopped completely.");
73 string remainder = string.Join(
" ", args);
74 GameObject o = (GameObject)AVR.Core.Utils.Misc.GlobalFind(remainder, typeof(GameObject));
77 AVR_DevConsole.error(
"Could not find object with name " + remainder);
81 o.SetActive(!o.activeSelf);
82 AVR_DevConsole.success(
"Toggled object " + o.name);
87 AVR_DevConsole.success(
"Installed packages:");
89 AVR_DevConsole.success(
"> AVR_CORE");
92 AVR_DevConsole.success(
"> AVR_AVATAR");
95 AVR_DevConsole.success(
"> AVR_MOTION");
98 AVR_DevConsole.success(
"> AVR_PHYS");
101 AVR_DevConsole.success(
"> AVR_UI");
104 AVR_DevConsole.success(
"> AVR_NET");
109 string remainder = string.Join(
" ", args.Skip(1));
110 if (args[0] ==
"props")
112 AVR_DevConsole.print(
"Displaying Avr_Prop labeled prefabs with query: " + remainder);
113 SetSearch(
"l:Avr_Prop " + remainder);
117 AVR_DevConsole.print(
"Displaying Avr_Ui labeled prefabs with query: " + remainder);
118 SetSearch(
"l:Avr_Ui " + remainder);
137 System.Type upb_t = System.Type.GetType(
"UnityEditor.ProjectBrowser, UnityEditor");
140 Object projectBrowser = Resources.FindObjectsOfTypeAll(upb_t)[0];
141 if (projectBrowser == null)
143 AVR_DevConsole.error(
"Could not get an active ProjectBrowser.");
149 System.Reflection.MethodInfo setSearchInfo = upb_t.GetMethod(
"SetSearch",
new[] { typeof(
string) });
151 setSearchInfo.Invoke(projectBrowser,
new object[] { searchstring });
153 catch (System.Exception e)
155 AVR_DevConsole.error(
"Encountered an exception while setting search-string. Do you not have a ProjectBrowser open, or are you using a different Unity version?");
156 AVR_DevConsole.error(
"Stacktrace: " + e.StackTrace);
Represents the players VR setup. Only one instance at a time is allowed.
static void SetSearch(string searchstring)
static IEnumerator StartXR()
static void InitCommands()
Class for the arc-vr developer's console. Functions as a singleton with only static members...
Contains constan values, settings etc. which can all be set through *.avr files. Duplicate settings w...
static Dictionary< string, string > settings
Dictionary containing all settings by their key. A setting declared as domain = { setting = true } wi...
static void prefabSearch(string[] args)
static void print(string s)
Print a given string on the console.
Declares a set of base DevConsole commands.
static void toggle_obj(string[] args)
static string get_string(string token)
Get a registered setting of the type string.
static void print_packages()
static void clear()
Clear console output entirely.