VRCOscLib is now released!
Download & import the .nupkg from the Releases page.
I can also download from NuGet Package Manager. See nuget.org for the NuGet package latest version.
Please check the Sample
for the combination with the actual application.
If you want to control avatar parameters, use classes in BuildSoft.VRChat.Osc.Avatar
.
using System;
using BuildSoft.VRChat.Osc.Avatar;
// get avatar config by avatar id.
var config = OscAvatarConfig.Create("avtr_XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")!;
foreach (var parameter in config.Parameters.Items)
{
Console.WriteLine($"{parameter.Name}: " +
$"input {(parameter.Input != null ? "○" : "×")}, " +
$"output {(parameter.Output != null ? "○" : "×")}"
);
}
using System;
using BuildSoft.VRChat.Osc.Avatar;
var config = OscAvatarConfig.CreateAtCurrent();
if (config == null) {
Console.WriteLine("Failed to get the current avatar, Do \"Reset Avatar\" or start VRChat.");
}
// Wait until you can get an avatar config.
config = await OscAvatarConfig.WaitAndCreateAtCurrentAsync();
using BuildSoft.VRChat.Osc.Avatar;
var config = await OscAvatarConfig.WaitAndCreateAtCurrentAsync();
config.Parameters["IntParameterName"] = 1;
config.Parameters["FloatParameterName"] = 12.2f;
config.Parameters["BoolParameterName"] = true;
or
using BuildSoft.VRChat.Osc;
OscParameter.SendAvatarParameter("IntParameterName", 1);
OscParameter.SendAvatarParameter("FloatParameterName", 12.3f);
OscParameter.SendAvatarParameter("BoolParameterName", true);
using System;
using System.Threading.Tasks;
using BuildSoft.VRChat.Osc.Avatar;
var config = await OscAvatarConfig.WaitAndCreateAtCurrentAsync();
await Task.Delay(1000);
Console.WriteLine($"parameterName = {config.Parameters["parameterName"]}");
If you want to use button input with OSC, use classes in BuildSoft.VRChat.Osc.Input
.
There are 2 kinds of input, OscAxisInput
can send a float value, and OscButtonInput
can send a boolean value, press or release.
using System.Threading.Tasks;
using BuildSoft.VRChat.Osc.Input;
OscAxisInput.LookVertical.Send(0.2f);
await Task.Delay(1000);
OscAxisInput.LookVertical.Send(0f);
OscButtonInput.Jump.Press();
await Task.Delay(1000);
OscButtonInput.Jump.Release();
If you want to use button input with OSC, use classes in BuildSoft.VRChat.Osc.Chatbox
.
using BuildSoft.VRChat.Osc.Chatbox;
OscChatbox.SendMessage("some message", direct: true);
using BuildSoft.VRChat.Osc.Chatbox;
OscChatbox.SendMessage("some message", direct: false);
using BuildSoft.VRChat.Osc.Chatbox;
using System.Threading.Tasks;
// typing during 3 second.
OscChatbox.SetIsTyping(true);
await Task.Delay(3000);
OscChatbox.SendMessage("some message", direct: true);