Sample Content

This is a Sample Content

This is a Sample.

This is code.

This block is a code block.
This is a second sentence in a code block.
// This is a C# code block.
string helloWorldString = "Hello, World!";
Console.WriteLine(helloWorldString);
  1. item1
  2. item2
  3. item3

  • item1
  • item2
  • item3

VRCOscLib

The OSC library for VRChat (.NET Standard)

Discord

VRCOscLib is now released!

How to Install

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.

Usage in code

Please check the Sample for the combination with the actual application.

About avatar parameters

If you want to control avatar parameters, use classes in BuildSoft.VRChat.Osc.Avatar.

e.g.) Get and use avatar config model

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 ? "○" : "×")}"
    );
}

e.g.) Get current avatar config model

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();

e.g.) Send avatar parameter

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);

e.g.) Get received avatar parameter

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"]}");

About button input

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.

e.g.) Send Input

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();

About Chatbox

If you want to use button input with OSC, use classes in BuildSoft.VRChat.Osc.Chatbox.

e.g.) Send a string to Chatbox

using BuildSoft.VRChat.Osc.Chatbox;

OscChatbox.SendMessage("some message", direct: true);

e.g.) Send a string to Chatbox UI

using BuildSoft.VRChat.Osc.Chatbox;

OscChatbox.SendMessage("some message", direct: false);

e.g.) Act like typing

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);