I was able to get a mortgage while still on my visas and before ILR. I had been in the UK, working continuously for five years. I know others who have managed to get mortgages earlier. You'll have fewer lending options and will pay a much higher mortgage rate, unfortunately.
I would talk with a mortgage broker (NOT a bank) and have them only present lenders who will be willing to lend to you and at what rates. If you are able to put down 40%, you shouldn't have to be working in the UK too long before you'll be able to qualify.
I just received ILR in September and we changed our mortgage product, saving £500 a month! So while I thought our interest rate was reasonable while on a visa, it's apparent we were paying WAY too much interest.
But yes, you will have no credit when coming to the UK. Imagine you are 18 all over again.