I dare say that Ukip's role in all this will be the subject of many theses to come. As has been pointed out, though, there's also the story of the collapse of Labour in Scotland, and the Lib Dems everywhere, both of which contributed to the Tory's majority. For sure, Cameron may have offered the referendum primarily because he was scared of Ukip -- or, more likely, of the Tory right deserting in their droves to join Ukip -- but he still only had the opportunity because anti-Tory Lib Dem supporters/protest voters deserted that party as well.
Politics is a messy business and I don't think it's as clear cut as Ukip's rise directly leading to the Leave vote. Still, they must have some credit (or blame?) for getting Brexit. But it's all indirect and now they are being brutally exposed as nothing but another "protest vote" party.
All of which feels rather ominous for the coming election. Taking Electoral calculus seriously, right now the Tories are heading for a strong majority. If Ukip's vote continues to flood back to the Tories, it'll just get stronger still of course -- the current Ukip vote share (predicted) being difference between majorities of around 150 and around 250.
Of course, as pointed out by many, local election voting patterns and general election patterns are different, even when only five weeks apart, but I think Tories could be forgiven for feeling hugely optimistic about the General Election after yesterday's results.