I recently came across the excellent article Visualizing Algorithms from Mike Bostock. If you have no idea what "sampling" means or what's Poisson-disc sampling, just read that article, it's beautifully explained.
In a nutshell, Poisson-disc sampling creates nice, uniform-looking randomness, without over-crowded or underpopulated spots. For example, imagine that you're trying to plant trees randomly on a 100m x 100m terrain. You could use a random number generator to pick two numbers between 0 and 100, go to that location and plant the tree there, then repeat for as many trees you want to plant. Unfortunately, this method will give you areas with too many trees and others with no trees at all, which may look unrealistic. With Poisson-disc sampling, you essentially say that you want all trees to be at least, say, 3 meters apart from each other, and at most 6 meters apart.
(If you think nobody plants trees that way, you've obviously never tried to plant trees in code :)
A few days after reading Mike's article, I found myself in a situation where I needed uniform-looking randomness for Of Dust And Dreams, the game that I'm working on, and I thought it would be a good opportunity to implement Bridson's Poisson-disc sampling algorithm. There are already a couple of implementations floating around for Unity, but this one is short, clean, and self-contained. It doesn't depend on anything else besides Unity.
So without further ado, here's a C# implementation of Bridson's Poisson-disc sampling algorithm for Unity:
If you were wondering what I've been doing those last few weeks, now you should have a pretty good idea what my days look like :)