CVROSC
CVROSC copied to clipboard
[Enhancement] Update AAS Menu upon OSC Change
Currently, if values controllable within the AAS menu are modified by OSC, you have to close the AAS menu and reopen it for the options to be updated with their new values. It would be more convenient if this was done when being modified by OSC directly.
I would imagine this could be done by gaining access to the AAS menu and changing the state of the buttons directly or by calling a method that refreshes it automatically instead.
I've been looking around for a bit to find a way to refresh it in real-time, but right now I wasn't able to find anything...
Will look into it more though, I could ask the developers about it!
I've been messing with it for a few hours now and found a very elegant one line solution. You will need to add cohtml.net.dll and Cohtml.Runtime.dll as resources from the game's Managed directory though for this to work.

EDIT: It's better to put it here than in the SetParameter function so that it only runs once after the entirety of the message or bundle has been processed.
Quick update on using this method. Although it works as intended, having too many OSC messages coming in at once can still overload the garbage collectors and crash the game from reloading the data for the menu too often. The rate of messages required for a crash can be as low as 5 per second, so an alternative to the previous workaround is preferred.
I think a better approach would now be to update the individual buttons and values directly than reloading the whole dataset using this event trigger, but I don't have the time right now to go through the menu's JS file to find the correct event / function to use.
You can find the file containing all the menu functionality in the game's directory at ChilloutVR\ChilloutVR_Data\StreamingAssets\Cohtml\UIResources\CVRTest\ui.js
You might be able to call the functions directly from C# using the cohtml API, but I haven't the foggiest idea how to do so aside from adding a listener within the ui.js file and triggering that with TriggerEvent().
As a temporary solution you could mark a flag when a variable is set, then check that variable every 1 or 2 seconds, and then correspondingly trigger that CVRAppActionLoadAvatarSettings
event or not. I can't think of a use case where the menu update would need to be instantly upon setting a parameter.