Ian McKellen, who has for many years been the most famous openly gay movie star, has attacked Hollywood timidity in depicting minorities onscreen.

In an interview with Time Out, McKellen, 78, was asked about the controversy surrounding the decision not to show the young Dumbledore as “explicitly gay” in the upcoming Fantastic Beasts and Where to Find Them sequel.

McKellen, who had been approached to play Dumbledore in the Harry Potter films, said: “Well, nobody looks to Hollywood for social commentary, do they? They only recently discovered that there were black people in the world.”

He continued: “Hollywood has mistreated women in every possible way throughout its history. Gay men don’t exist.”

McKellen credited 1998’s Gods and Monsters – in which he played director James Whale – as triggering a new climate of acceptance in the industry, saying it “was the beginning of Hollywood admitting that there were gay people knocking around, even though half of Hollywood is gay”.

On Tuesday a new report from advocacy group GLAAD found only 12.8% of mainstream films featured LGBTQ characters. They have called for the number to rise to 50% by 2024.

McKellen came out publicly in 1988 and has been an industrious campaigner for equal rights ever since. He was speaking to promote documentary McKellen: Playing the Part, which screens in cinemas on Sunday, followed by a live Q&A with the actor and Graham Norton.