Skip to content

Commit eb6fce2

Browse files
committed
egg samples
1 parent d21ba92 commit eb6fce2

2 files changed

Lines changed: 68 additions & 1 deletion

File tree

OVRSharp/Overlay.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ public Overlay(string key, string name, bool dashboardOverlay = false)
238238
if (OpenVR.Overlay == null)
239239
throw new NullReferenceException("OpenVR has not been initialized. Please initialize it by instantiating a new Application.");
240240

241-
var err = EVROverlayError.None;
241+
EVROverlayError err;
242242

243243
if (dashboardOverlay)
244244
err = OpenVR.Overlay.CreateDashboardOverlay(key, name, ref overlayHandle, ref thumbnailHandle);

README.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,73 @@ Right now, our main goal with this is to make working with the overlay API easie
66

77
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.
88

9+
So you can do this:
10+
11+
```csharp
12+
Application app;
13+
14+
try {
15+
app = new Application(Application.ApplicationType.Overlay);
16+
} catch(OpenVRSystemException e) {
17+
// Errors are exceptions!
18+
}
19+
20+
var overlay = new Overlay("cool_overlay", "Cool Overlay", true) {
21+
WidthInMeters = 3.8f
22+
};
23+
24+
overlay.SetTextureFromFile(@"C:\path\to\file.png");
25+
overlay.SetThumbnailTextureFromFile(@"C:\path\to\thumb.png");
26+
```
27+
28+
Instead of this:
29+
30+
```csharp
31+
var err = EVRInitError.None;
32+
var vrSystem = OpenVR.Init(ref err, EVRApplicationType.VRApplication_Overlay);
33+
34+
if (err != EVRInitError.None)
35+
{
36+
// whatever error handling
37+
}
38+
39+
// Create a dashboard overlay
40+
var overlayErr = EVROverlayError.None;
41+
42+
ulong overlayHandle;
43+
ulong thumbnailHandle;
44+
45+
overlayErr = OpenVR.Overlay.CreateDashboardOverlay("cool_overlay", "Cool Overlay", ref overlayHandle, ref thumbnailHandle);
46+
47+
if (overlayErr != EVROverlayError.None)
48+
{
49+
// whatever error handling
50+
}
51+
52+
overlayErr = OpenVR.Overlay.SetOverlayWidthInMeters(overlayHandle, 3.8f);
53+
54+
if (overlayErr != EVROverlayError.None)
55+
{
56+
// whatever error handling
57+
}
58+
59+
// Set the dashboard overlay up. First, the main overlay's texture
60+
overlayErr = OpenVR.Overlay.SetOverlayFromFile(overlayHandle, @"C:\path\to\file.png");
61+
62+
if (overlayErr != EVROverlayError.None)
63+
{
64+
// whatever error handling
65+
}
66+
67+
// Then the thumbnail.
68+
overlayErr = OpenVR.Overlay.SetOverlayFromFile(thumbnailHandle, @"C:\path\to\thumb.png");
69+
70+
if (overlayErr != EVROverlayError.None)
71+
{
72+
// whatever error handling
73+
}
74+
```
75+
976
Docs coming Soon™️.
1077

1178
## Examples

0 commit comments

Comments
 (0)