I'm so sorry you had to deal with this, OP. I don't want you to leave, and nor do any of my family and friends.
My DH has been in the UK for 14 years, and is now a British citizen. He never really encountered much overt racism until after the referendum. I think that, thanks to the likes of Farage and his cronies, people now feel that it is legitimate to accept these views.
Ultimately, OP, I think it boils down to ignorance and a dearth of critical thinking skills. Successive governments have effectively failed huge sections of the population. Our housing stock is inadequate, we have failed to equip people with the right skills and attributes to function effectively in a post-manufacturing economy, there has been chronic under-investment in our infrastructure and our public services, and then to top it all off, the poorest in our society have faced swingeing cuts to their income. Understandably, people are looking for someone to blame. Farage and the Daily Mail tell them that immigrants are the problem. The other main parties don't want to lose ground to UKIP, so they jump on the bandwagon. It becomes the accepted wisdom that immigration is the root of all our problems, and hence controlling immigration becomes the holy grail solution.
It isn't really about immigrants. It's about people's dissatisfaction with their own lots in life. Immigrants are just a convenient scapegoat.
I hope you are ok, OP. It's very distressing to suddenly feel alienated in a place that you regarded as home.