Skip to content

Instantly share code, notes, and snippets.


Ralph Barbagallo flarb

View GitHub Profile
flarb / Controller.cs
Created Dec 30, 2016
Simple Daydream controller shake / direction detection. Modified from Daydream sample controller code and a low pass filter example I found on stack overflow
View Controller.cs
using UnityEngine;
using System.Collections;
public class Controller : MonoBehaviour {
public GameObject controllerPivot;
public float accelerometerUpdateInterval = 1f / 60f;
public float lowPassKernelWidthInSeconds = 1f;
public float shakeDetectionThreshold = 2f;
flarb / .gitignore
Created Jul 3, 2016
Proper gitignore for HoloLens project (includes UWP folder)
View .gitignore
# Autogenerated VS/MD solution and project files
flarb / StareButton.cs
Created May 23, 2015
This is a 'stare button' for Google Cardboard apps where you just want to stare at a button over time to select it.
View StareButton.cs
using System;
using System.Reflection;
using UnityEngine;
using System.Collections;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;
public class StareButton : MonoBehaviour, IEventSystemHandler, IPointerExitHandler, IPointerEnterHandler, ISelectHandler {
flarb / SDKSwap.cs
Created May 23, 2015
Swap between Unity3D Google Cardboard and Gear VR / OVR Mobile SDKs. It swaps out the Android manifest files when you switch platforms--pretty much all you need (aside from wrapping the APIs) to switch platforms.
View SDKSwap.cs
using UnityEngine;
using System.Collections;
using UnityEditor;
using System.IO;
public class SDKSwap : EditorWindow {
static string _cardboardPath;
static string _OVRPath;
flarb / VRInputModule.cs
Created Aug 20, 2014
Lets you use a VR world space cursor with World Space Canvases in Unity3D 4.6. Add this to the EventSystem object. Put some box colliders on your buttons in the World Space Canvas. Then, do a trace to see if you're looking at a menu object--if the trace hits one of those buttons, pass it to SetTargetObject. See for a longer e…
View VRInputModule.cs
using UnityEngine;
using UnityEngine.EventSystems;
//by Ralph Barbagallo
public class VRInputModule : BaseInputModule {
View .hgignore
syntax: glob
flarb / Pixel2UV
Created Feb 18, 2013
Converts pixel coordinates in a texture to UV coordinates in Unity3D.
View Pixel2UV
Vector2 uv = new Vector2((float)myMarker.pixelCoords.x / (float)renderer.material.mainTexture.width, 1f - (float)myMarker.pixelCoords.y / (float)renderer.material.mainTexture.height);
flarb / MapUtils.cs
Created Feb 18, 2013
A port of this PHP code: To C# in Unity3D to convert google maps lat/lng to pixel coordinates and vice versa.
View MapUtils.cs
using UnityEngine;
using System.Collections;
public class MapUtils {
static float GOOGLEOFFSET = 268435456f;
static float GOOGLEOFFSET_RADIUS = 85445659.44705395f;//GOOGLEOFFSET / Mathf.PI;
static float MATHPI_180 = Mathf.PI/180f;
static private float preLonToX1 = GOOGLEOFFSET_RADIUS * (Mathf.PI/180f);
View MeshPixelTools.cs
using UnityEngine;
using System.Collections;
public class MeshPixelTools : MonoBehaviour {
// Use this for initialization
void Start () {
flarb / PlayScene.cs
Created Dec 20, 2012
Lets you save the currently selected Unity3D scene. Then automatically load and run the saved scene via keyboard shortcut. If you break up your Unity3D projects into multiple scenes--including a loading scene--this saves a lot of manual switching of scenes.
View PlayScene.cs
using UnityEngine;
using System.Collections;
using UnityEditor;
* Written by Ralph A. Barbagallo III
* I wrote this becuase I was sick of switching scenes to play my loader scene and test my game.
You can’t perform that action at this time.