Skip to content

Instantly share code, notes, and snippets.

View davepape's full-sized avatar

Dave Pape davepape

View GitHub Profile
@davepape
davepape / dynamicTexture.cs
Created November 19, 2019 18:36
Create a Texture2D from scratch, and modify it slightly each frame.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class dynamicTexture : MonoBehaviour
{
public int width=32;
public int height=32;
void Start()
@davepape
davepape / gpw.cs
Last active November 19, 2019 18:46
Convert SEDAC global population data into a texture.
/*
Visualize data from SEDAC's Gridded Population of the World data set - https://sedac.ciesin.columbia.edu/data/set/gpw-v4-population-count-rev11
Parses the population counts and converts the data into a greyscale texture.
The data file must be in ASCII format, with its extension changed to ".txt" in order for Unity to recognize it as a TextAsset.
*/
using System.Collections;
using System.Collections.Generic;
using System;
using UnityEngine;
@davepape
davepape / 360VideoSphere.cs
Last active March 5, 2020 23:59
Create a sphere that a 360-video (or still image) texture can be applied to. This is the same as LatLonSphere.cs, except that the vertex order is tweaked so that the sphere will be visible from the inside, rather than outside.
/*
Create Unity mesh data for a sphere, which can be used with a video (or still) texture from a 360-camera.
The mesh is created so that it will be visible when the viewer is inside, rather than outside, of the sphere, with Unity's default backface-culling mode.
Texture coordinates are based on latitude & longitude (ie an equirectangular map projection) which matches the images from the 360-cameras that we use.
*/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LatLonSphere : MonoBehaviour
@davepape
davepape / Navigator.cs
Last active November 1, 2021 13:38
simple steamvr navigator
// Super-simple navigation for SteamVR. Attach this script to a Unity GameObject, and make the SteamVR CameraRig a child of that object.
// Travels in the direction that the left controller is pointing, speed scaled by how much the trigger is pulled.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Valve.VR;
public class Navigator : MonoBehaviour
{
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class QuitOnEsc : MonoBehaviour
{
void Start()
{
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class QuitButton : MonoBehaviour
{
void Start()
{
}