Skip to content

Instantly share code, notes, and snippets.

@N-Carter
N-Carter / BitfieldPropertyDrawer.cs
Created September 9, 2014 12:08
BitfieldPropertyDrawer
using UnityEngine;
using UnityEditor;
using System.Collections;
[CustomPropertyDrawer(typeof(BitfieldPropertyAttribute))]
public class BitfieldPropertyDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
EditorGUI.BeginProperty(position, label, property);
@N-Carter
N-Carter / UIScrollList.cs
Created August 31, 2014 21:55
UIScrollList
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
using System.Collections;
public class UIScrollList : MonoBehaviour
{
[SerializeField] protected RectTransform m_RowPrefab;
[SerializeField] protected ScrollRect m_ScrollRect;
[SerializeField] protected UITest m_UITest;
@N-Carter
N-Carter / Spatial Cutoff Test.shader
Created January 15, 2014 10:21
A shader that discards the part of a mesh that's on one side of a plane.
// Upgrade NOTE: replaced 'PositionFog()' with multiply of UNITY_MATRIX_MVP by position
// Upgrade NOTE: replaced 'V2F_POS_FOG' with 'float4 pos : SV_POSITION'
// Upgrade NOTE: replaced 'glstate.matrix.projection' with 'UNITY_MATRIX_P'
Shader "Mine/Spatial Cutoff Test"
{
Properties
{
_Color ("Main Color", Color) = (1,1,1,1)
@N-Carter
N-Carter / gist:7704356
Last active December 29, 2015 17:29
System.Environment.SpecialFolder paths on OSX 10.8 with Unity 4.3.1's built-in Mono
0 Desktop: /Users/username/Desktop
2 Programs:
5 Personal: /Users/username
5 MyDocuments: /Users/username
6 Favorites:
7 Startup:
8 Recent:
9 SendTo:
11 StartMenu:
13 MyMusic: /Users/username/Music
@N-Carter
N-Carter / OnlyNonVoidReturnTypes.cs
Created May 18, 2013 10:38
Prints only methods with non-void return types
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
class OnlyNonVoidReturnTypes
{
class C
{
public void Void() {}
@N-Carter
N-Carter / .gitignore
Last active December 17, 2015 05:18
Unity .gitignore
Builds
Debugging Output
Screenshots
Source Material
Temp
*.csproj
*.pidb
*.sln
*.unityproj
*.userprefs
@N-Carter
N-Carter / Player.cs
Created May 10, 2013 08:51
Player script from Pacing, demonstrating multitouch.
using UnityEngine;
using System.Collections;
public class Player : MonoBehaviour
{
[SerializeField] protected Hint m_HintPrefab;
[SerializeField] protected Footfall m_FootfallPrefab;
[SerializeField] protected Material m_FootfallMaterial;
[SerializeField] protected EndlessTiles m_EndlessTiles;
[SerializeField] protected GUIText m_LivesText;
@N-Carter
N-Carter / SuperChaseCamera.cs
Created April 4, 2013 09:37
Chase camera that works in any orientation
using UnityEngine;
using System.Collections;
public class SuperChaseCamera : MonoBehaviour
{
public Transform m_Target;
public Vector3 m_TargetOffset = new Vector3(0.0f, 1.0f, 0.0f);
public Vector3 m_ChasingOffset = new Vector3(0.0f, 1.0f, -10.0f);
public Vector3 m_LeadingOffset = new Vector3(0.0f, 1.0f, 20.0f);
public float m_NormalisingFactor = 0.1f;
@N-Carter
N-Carter / AlphaOnly.shader
Created March 30, 2013 21:03
AlphaOnly.shader
Shader "Mine/Alpha Only"
{
Properties
{
_MainTex ("Base (RGB)", 2D) = "white" {}
_MainColor ("Tint Color", Color) = (1, 1, 1, 1)
}
SubShader
{
Tags { "RenderType"="Transparent" }
@N-Carter
N-Carter / Tile.cs
Last active December 14, 2015 21:19
Tile class to go with EndlessTiles
using UnityEngine;
using System.Collections;
public class Tile : MonoBehaviour
{
[SerializeField] TextMesh m_TextMesh;
protected EndlessTiles m_EndlessTiles;
protected bool m_Touched;
protected int m_TileIndex;