Sir Ian McKellen, who portrayed Gandalf  in the "Lord of the Rings" movies, regrets not coming out sooner.

In his interview with the Huffington Post, he said that had he revealed the truth about his sexual identity earlier, things would have been so much better in his life.

"I regret and always shall that I didn't see the significance of coming out at a much earlier date because I think I would have been a different person and a happier one. Self-confidence is the most important thing that anybody can have. You don't have that if part of you is ashamed or hiding something. I can reassure people who don't feel they're able to, the world will like you better because people like honesty and authenticity," the actor, who is also known for his role as "Magneto" in the "X-Men" movies, said.

The 76-year-old actor who came out in 1988 grew up at a time when there was still discrimination toward lesbian, gay, bisexual and transgender individuals.

"We didn't have the language to talk about it. No one in England talked about being gay when I was growing up -- the word hadn't been invented. 'Queer' was the word that was used about us. It was against the law to have sex with another man. If we were to express ourselves, we would define ourselves as being criminal. So, of course, you didn't talk about it, " the seasoned actor explained.

It took a while before the two-time Oscar nominee finally found the courage to inform his family about his sexual orientation, and when he did, they did not give a fuss about it. In fact, when he told his step mother, he was surprised to discover that she had already known his secret from the time she met him.

He was also thankful that he did not experience the "oppression of the closet" being a theater person and an actor. In fact, his career took off and he played iconic roles that a lot of people will remember for a very long time.

In his BuzzFeed interview in 2014, he recounted how X-Men director Bryan Singer convinced him to play Magneto.

"I was sold it by Bryan who said, 'Mutants are like gays. They're cast out by society for no good reason,' And, as in all civil rights movements, they have to decide: Are they going to take the Xavier [Stewart's character] line - which is to somehow assimilate and stand up for yourself and be proud of what you are, but get on with everybody - or are you going to take the alternative view - which is, if necessary, use violence to stand up for your own rights. And that's true. I've come across that division within the gay rights movement."

McKellen will portray the role of Cogsworth, the clock, in the upcoming Disney film, "Beauty and the Beast" starring Emma Watson, Dan Stevens, Luke Evans and Josh Gad. The live-action film will be directed by Bill Condon and is set for release on March 17, 2017.