Added #if UNITY_EDITOR liberally to allow compilation of standalone player.