Skip to content

Instantly share code, notes, and snippets.

View corycorvus's full-sized avatar

Cory Corvus corycorvus

View GitHub Profile
@corycorvus
corycorvus / .gitignore
Created December 29, 2020 02:24
Unity Git Ignore
# .gitignore for Unity by Cory Corvus
# Ignore everything
/*
/*/
# Keep assets & project settings
!/Assets/
!/ProjectSettings/
@corycorvus
corycorvus / TestUDP.cs
Created September 15, 2020 20:51
UDP Test (Unity Distribution Portal)
using UnityEngine;
using UnityEngine.UDP;
public class TestUDP : MonoBehaviour
{
void Start()
{
InitListener initListener = new InitListener();
LicenseCheckListener licenseCheckListener = new LicenseCheckListener();
using System.Collections;
using UnityEngine;
using Viveport;
// Viveport DRM Documentation:
// https://developer.vive.com/resources/documentation/viveport-sdk/apis/drm-api/
// NOTE: To use Unity functions such as Application.Quit within callback functions requires running on the main thread.
// Please attach 'MainThreadDispatcher.cs' to an object in your scene
// https://developer.vive.com/resources/documentation/viveport-sdk/integration-with-viveport-sdk/for-unity-developers/using-the-unity-main-thread-dispatcher-script/
void EyeCalibration()
{
Debug.Log("Start Calibration");
int result = ViveSR.anipal.Eye.SRanipal_Eye_API.LaunchEyeCalibration(System.IntPtr.Zero); // Ptr not implemented so using Zero
Debug.Log("Finish Calibration: " + result);
}
@corycorvus
corycorvus / HapticPulse.cs
Created May 19, 2020 18:46
Haptic Vibrate Controller SteamVR and Oculus
using UnityEngine;
using UnityEngine.XR;
using Valve.VR;
// simple library and examples for XR haptics
// note: controllers must be tracking to use haptics
// other examples: https://vrtoolkit.readme.io/docs/vrtk_interacthaptics
public static class HapticPulse
@corycorvus
corycorvus / steamvr_device_poweroff.cs
Last active July 16, 2021 20:01
Power off SteamVR device
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = "C:\\Program Files (x86)\\Steam\\steamapps\\common\\SteamVR\\tools\\lighthouse\\bin\\win64\\lighthouse_console.exe";
process.StartInfo.Arguments = "/serial 81F6B76702 poweroff";
process.StartInfo.UseShellExecute = true;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
process.Start();
@corycorvus
corycorvus / vive_tracker_serial.cpp
Created May 15, 2020 05:52
Get the serial number of a VIVE tracker with C++
char serialNumber[1024];
vr::VRSystem()->GetStringTrackedDeviceProperty(deviceID, vr::Prop_SerialNumber_String, serialNumber, sizeof(serialNumber));
printf("Serial Number = %s \n", serialNumber);
@corycorvus
corycorvus / DetectVR.cs
Last active May 14, 2023 08:29
Detect VR HMD and controller
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR;
using Valve.VR;
/// <summary>
/// These are a few different ways to detect the current VR HMD and controller type.
/// - Unity XR api
/// - Unity Input api
/// - SteamVR plugin
using UnityEngine;
using Viveport;
public class QuitGoHome
{
const int SUCCESS = 0;
private static bool isSubscriber = false;
static void Quit()
{
@corycorvus
corycorvus / OculusPlatformEntitlementCheck.cs
Created October 11, 2017 06:33
Oculus Platform Entitlement Check Example
using UnityEngine;
using UnityEngine.SceneManagement;
using Oculus.Platform;
#if UNITY_4 || UNITY_5
using UnityEngine.Events;
#endif
/*
Step 1: Download & Install Oculus Platform SDK
Step 2: Update your App ID in the Editor