Tested/updated slightly for Unity 4.6.1f1