Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chanyavrc/vrcosclib
The OSC library for VRChat (.NET Standard)
https://github.com/chanyavrc/vrcosclib
csharp csharp-library osc vrc vrchat vrchat-osc
Last synced: 24 days ago
JSON representation
The OSC library for VRChat (.NET Standard)
- Host: GitHub
- URL: https://github.com/chanyavrc/vrcosclib
- Owner: ChanyaVRC
- License: mit
- Created: 2022-02-21T12:53:24.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-05-19T13:51:34.000Z (over 1 year ago)
- Last Synced: 2024-10-12T14:21:39.516Z (24 days ago)
- Topics: csharp, csharp-library, osc, vrc, vrchat, vrchat-osc
- Language: C#
- Homepage:
- Size: 214 KB
- Stars: 46
- Watchers: 6
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
VRCOscLib
The OSC library for VRChat (.NET Standard)
**VRCOscLib is now released!**
## How to Install
Download & import the .nupkg from the [Releases](https://github.com/ChanyaVRC/VRCOscLib/releases) page.
I can also download from [NuGet Package Manager](https://docs.microsoft.com/nuget/quickstart/install-and-use-a-package-in-visual-studio). See [nuget.org](https://www.nuget.org/packages/VRCOscLib/) 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
```cs
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
```cs
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
```cs
using BuildSoft.VRChat.Osc.Avatar;var config = await OscAvatarConfig.WaitAndCreateAtCurrentAsync();
config.Parameters["IntParameterName"] = 1;
config.Parameters["FloatParameterName"] = 12.2f;
config.Parameters["BoolParameterName"] = true;
```or
```cs
using BuildSoft.VRChat.Osc;OscParameter.SendAvatarParameter("IntParameterName", 1);
OscParameter.SendAvatarParameter("FloatParameterName", 12.3f);
OscParameter.SendAvatarParameter("BoolParameterName", true);
```#### e.g.) Get received avatar parameter
```cs
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
```cs
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
```cs
using BuildSoft.VRChat.Osc.Chatbox;OscChatbox.SendMessage("some message", direct: true);
```#### e.g.) Send a string to Chatbox UI
```cs
using BuildSoft.VRChat.Osc.Chatbox;OscChatbox.SendMessage("some message", direct: false);
```#### e.g.) Act like typing
```cs
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);
```