Skip to content

Instantly share code, notes, and snippets.

/**
* @author Lee Grey / Jonathan Hopcroft
*
* seeded random number generator
* based on Rndm by Grant Skinner
* https://github.com/gskinner/AS3Libs/blob/master/Rndm/com/gskinner/utils/Rndm.as
*
* Incorporates implementation of the Park Miller ( 1988 ) "minimal standard" linear
* congruential pseudo-random number generator by Michael Baczynski, www.polygonal.de.
* ( seed * 16807 ) % 2147483647
@leegrey
leegrey / ProcessTimer.cs
Created February 13, 2017 22:54
A small debug util for timing chunks of code in Unity / C#
using System.Collections.Generic;
using System.Diagnostics;
using Debug = UnityEngine.Debug;
/*
USAGE:
ProcessTimer.Start("unique_process_id");
// do stuff
ProcessTimer.End("unique_process_id", "An optional additional message to display with results");
/*
Basic Sprite Shader for aligning pixel art to the same grid, based on the Unity Sprite Shader.
Create one Material where you assign the same Pixels Per Unit value you use on your imported Sprites,
then reuse this Material on all appropriate Sprite Renderers.
(As far as I know there's no possiblity to get this value automatically.)
This is not for scaled or rotated artwork. If you need those features, look at low res render textures.
Use this however you want.
@leegrey
leegrey / PixelController.cs
Created June 22, 2017 11:35
A Unity3D class for snapping pixel art to multiples of a whole (design scale) pixel
using UnityEngine;
/*
A Unity3D class for snapping pixel art to multiples of a whole (design scale) pixel
Use in conjunction with an appropriately scaled Otho Camera
License: MIT
Written by Lee Grey (@mothteeth)
*/