Skip to content

Instantly share code, notes, and snippets.

View davepape's full-sized avatar

Dave Pape davepape

View GitHub Profile
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class QuitButton : MonoBehaviour
{
void Start()
{
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class QuitOnEsc : MonoBehaviour
{
void Start()
{
}
@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
{
@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 / 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 / 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 / readQuakes.cs
Created November 12, 2019 18:37
Starting point for visualization project - read earthquake data from the USGS geojson data feed.
/* Example of reading earthquake data from the USGS data feed.
Starting point for visualization project.
This script requests GEOJson formatted data, then parses it and prints some of the information.
It requires the JSONObject class for Unity, which can be downloaded from https://github.com/mtschoen/JSONObject
*/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
@davepape
davepape / LatLonSphere.cs
Created November 12, 2019 06:12
Create a sphere, as a grid of points regularly spaced in latitude and longitude
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LatLonSphere : MonoBehaviour
{
public int latRes=20, lonRes=40;
void Start()
{
@davepape
davepape / showInput.cs
Last active October 24, 2019 20:56
Display the state of a few example Unity Input values
// Display the state of a few example Unity Input values
// This script should be attached to a text object.
// It uses the "Jump" and "Cancel" buttons to switch between very slow framerate & 60 fps, so that the behavior of GetButtonDown & GetButtonUp can be seen.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class showInput : MonoBehaviour
{
@davepape
davepape / noiseland2.cs
Last active November 6, 2018 18:47
Combination of noiseland.cs & noisetex.cs - creates landscape geometry and a texture to apply to the geometry
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class noiseland2 : MonoBehaviour {
public int numRows=10, numCols=10;
public float minX=-1, maxX=1, minY=-1, maxY=1;
public int tex_width=256;