OVRSharp 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package OVRSharp --version 1.0.1
NuGet\Install-Package OVRSharp -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OVRSharp" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add OVRSharp --version 1.0.1
#r "nuget: OVRSharp, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install OVRSharp as a Cake Addin
#addin nuget:?package=OVRSharp&version=1.0.1

// Install OVRSharp as a Cake Tool
#tool nuget:?package=OVRSharp&version=1.0.1

OVRSharp

OVRSharp is a high-level idiomatic C# interface for working with the OpenVR API.

Installation

Note: OVRSharp comes with its own version of openvr_api.dll and will automatically copy it to your project's output directory.

OVRSharp is available on NuGet, so you can install it just like any other NuGet package:

# .NET CLI
dotnet add package OVRSharp

# VS PowerShell
Install-Package OVRSharp

Usage

Right now, our main goal with this is to make working with the overlay API easier and more C#-like, as well as being entirely platform-agnostic. So you could use this all on its own in your own .NET Core project, or throw it into Unity and work with it there.

Later on, we plan on supporting basically the entirety of the OpenVR API, so you don't need to deal with pointers and stuff. Just write C# as you would expect.

So you can do this:

Application app;

try {
  app = new Application(Application.ApplicationType.Overlay);
} catch(OpenVRSystemException e) {
  // Errors are exceptions!
}

var overlay = new Overlay("cool_overlay", "Cool Overlay", true) {
  WidthInMeters = 3.8f
};

overlay.SetTextureFromFile(@"C:\path\to\file.png");
overlay.SetThumbnailTextureFromFile(@"C:\path\to\thumb.png");

Instead of this:

var err = EVRInitError.None;
var vrSystem = OpenVR.Init(ref err, EVRApplicationType.VRApplication_Overlay);

if (err != EVRInitError.None)
{
  // whatever error handling
}

// Create a dashboard overlay
var overlayErr = EVROverlayError.None;

ulong overlayHandle;
ulong thumbnailHandle;

overlayErr = OpenVR.Overlay.CreateDashboardOverlay("cool_overlay", "Cool Overlay", ref overlayHandle, ref thumbnailHandle);

if (overlayErr != EVROverlayError.None)
{
  // whatever error handling
}

overlayErr = OpenVR.Overlay.SetOverlayWidthInMeters(overlayHandle, 3.8f);

if (overlayErr != EVROverlayError.None)
{
  // whatever error handling
}

// Set the dashboard overlay up. First, the main overlay's texture
overlayErr = OpenVR.Overlay.SetOverlayFromFile(overlayHandle, @"C:\path\to\file.png");

if (overlayErr != EVROverlayError.None)
{
  // whatever error handling
}

// Then the thumbnail.
overlayErr = OpenVR.Overlay.SetOverlayFromFile(thumbnailHandle, @"C:\path\to\thumb.png");

if (overlayErr != EVROverlayError.None)
{
  // whatever error handling
}

If you encounter anything that is not natively supported by OVRSharp, you can always use the internal Valve.VR APIs. An instance of CVRSystem is accessible through Application, as OVRSystem.

If you run into something you would really like to see supported, feel free to open an issue describing your use case! That will help us prioritize what functionality to add next.

Examples

OVRSharp is currently being used in WhereIsForward, and in some unreleased projects.

License

MIT

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on OVRSharp:

Package Downloads
OVRSharp.Graphics.DirectX

DirectX implementation of OVRSharp graphics APIs

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on OVRSharp:

Repository Stars
galister/WlxOverlay
A simple OpenVR overlay for Wayland and X11 desktops