Skip to content

Instantly share code, notes, and snippets.

@N-Carter
N-Carter / gist:1858645
Created February 18, 2012 10:29
Mono SpecialFolders on OSX
using System;
class Test
{
static int Main(String[] argv)
{
var names = Enum.GetNames(typeof(Environment.SpecialFolder));
var values = Enum.GetValues(typeof(Environment.SpecialFolder));
for(int i = 0; i < names.Length; ++i)
Console.WriteLine("{0} {1}: {2}", (int)values.GetValue(i), names[i], Environment.GetFolderPath((Environment.SpecialFolder)values.GetValue(i)));
@N-Carter
N-Carter / Rain.cs
Created January 2, 2012 13:05
Raycast rain particle system
using UnityEngine;
using System.Collections;
public class Rain : MonoBehaviour
{
[SerializeField] protected ParticleEmitter m_ParticleEmitter;
[SerializeField] protected Splashes m_Splashes;
[SerializeField] protected float m_Width = 10.0f;
@N-Carter
N-Carter / SpaceDust.cs
Created December 28, 2011 02:21
Space dust particles
using UnityEngine;
using System.Collections;
public class SpaceDust : MonoBehaviour
{
public float m_Size = 1.0f; // Halfwidth of the particle volume
public float m_MinBrightness = 0.2f;
public float m_MaxBrightness = 1.0f;
protected ParticleEmitter m_ParticleEmitter;
@N-Carter
N-Carter / ReflectiveBeam.cs
Created December 20, 2011 14:39
A beam that can be reflected multiple times
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class ReflectiveBeam : MonoBehaviour
{
[SerializeField] protected LineRenderer m_LineRenderer;
[SerializeField] protected float m_MaximumDistance = 10.0f;
[SerializeField] protected int m_NumBounces = 10;
@N-Carter
N-Carter / EditorActions.cs
Created December 18, 2011 11:44
EditorActions.UpdateLayerEnum()
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.IO;
public class EditorActions
{
[MenuItem ("Toolkit/Tags and Layers/Update Layer.cs")]
static void UpdateLayerConstants()
{
@N-Carter
N-Carter / Path.cs
Created November 15, 2011 08:27
Path class
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
[AddComponentMenu("Paths/Path")]
public class Path : MonoBehaviour, IEnumerable<Path.Segment>
{
[System.Serializable]
public class Waypoint : System.ICloneable
@N-Carter
N-Carter / PathEditor.cs
Created November 15, 2011 08:25
Custom inspector for Path objects
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
[CustomEditor(typeof(Path))]
public class PathEditor : Editor
{
protected Path m_Path;
@N-Carter
N-Carter / ParticleInjector.cs
Created November 14, 2011 16:00
Share particle emitter between multiple injectors
using UnityEngine;
using System.Collections;
// This component can emit particles into one or more ParticleEmitters. As several ParticleInjectors can emit to a shared set of
// ParticleEmitters, this allows you to save draw calls by having fewer separate particle systems.
//
// Note that when a ParticleEmitter's Simulate In World Space checkbox is off, it's OK to attach ParticleInjectors to separate
// hierarchies and move them independently. If it's turned on, the ParticleInjectors really need to be children of the emitter
// for the emission behaviour to make sense.
@N-Carter
N-Carter / StickOnContact.cs
Created September 3, 2011 09:36
Adding a HingeJoint component
using UnityEngine;
using System.Collections;
public class StickOnContact : MonoBehaviour
{
public Collider m_Contactor;
void OnCollisionEnter(Collision collisionInfo)
{
foreach(ContactPoint contact in collisionInfo.contacts)
@N-Carter
N-Carter / SpatialCutoffTest.shader
Created August 21, 2011 20:05
Geometry clipping shader
Shader "Mine/Spatial Cutoff Test"
{
Properties
{
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB)", 2D) = "white" {}
_Cutoff ("Cutoff", Float) = 1
}
SubShader