• Several celebrities continued to work together after splitting such as Robert Pattinson and Kristen Stewart
  • Kaley Cuoco continued to be close with "The Big Bang Theory" co-star Johnny Galecki after their breakup
  • Nina Dobrev once said her split with "Vampire Diaries" co-star Ian Somerhalder did not affect the love she had for him

Robert Pattinson, Kristen Stewart, Ian Somerhalder, Nina Dobrev and several other celebrities have something in common: they fell in love with their co-stars. But while this is nothing new, the situation becomes tricky when they hit a rough patch in the relationship and decide to part ways.

Working together with an ex can be an exhausting experience, but several celebrities have shown that one can keep their professionalism intact even when the real-life romance has come to an end.

Here are a few exes who continued romancing each other onscreen despite parting ways in real life.

Robert Pattinson and Kristen Stewart

Pattinson and Stewart rose to superstardom beginning with the release of "Twilight" in 2008, with their off-screen romance adding to the appeal of the movies.

However, their relationship started experiencing cracks in 2012 when Stewart was photographed getting cozy with her married "Snow White And The Huntsman" director, Rupert Sanders. While cheating rumors raged on, both Stewart and Pattinson had to spend time together to promote "The Twilight Saga: Breaking Dawn Part 2."

Pattinson and Stewart finally ended their relationship in 2013.

Ian Somerhalder and Nina Dobrev

Somerhalder and Dobrev started dating in 2011 after meeting on the set of "The Vampire Diaries." Despite their romance losing steam in 2013, the couple continued to work together in the vampire drama.

On working with Somerhalder despite their breakup, Dobrev told E! News in January 2015 that their split did not affect the love she had for him.

"I have an enormous amount of respect and love for him and everyone," she explained. "It doesn't change. It shouldn't. Otherwise, why were you with them?"

Johnny Galecki and Kaley Cuoco

Johnny Galecki and Kaley Cuoco played the characters Leonard and Penny on “The Big Bang Theory” for almost a decade after their romance ended.

In an interview, Cuoco had called Galecki one of her best friends.

"We dated, like, five years ago, so I think we've both moved on," Cuoco, who was still married to first husband Ryan Sweeting at the time, said on "Watch What Happens Live" in 2015.

"Johnny's actually one of my best friends," she continued. "It's a situation that ended well—I understand sometimes it doesn't, [could've gone] horrible, but he's one of my dearest friends, and Ryan loves him. Johnny loves [Ryan]...It's been great, I got lucky."

Chad Michael Murray and Sophia Bush

Chad Michael Murray and Sophia Bush, who played Lucas and Brooke on "One Tree Hill," continued to be a part of the show even after their five-month marriage ended.

Speaking about how she coped with the experience of working with her ex, Bush said that she learned to embrace the situation because her job was her priority.

"At the end of the day, we're grownups, and I actually think it's interesting that when people split in a way that's unpleasant, they usually just go on quite literally hating each other—or the person in my situation hates the other person, whatever," Bush said on "Watch What Happens Live" in 2014.

"But when you have to work with somebody for another half a decade, you kind of have to deal with it," she continued. "Because for me, at the end of the day, my job is my priority. And so I think at the end of it, it really let me just let go of it."

Mindy Kaling and B.J. Novak

Mindy Kaling and B.J. Novak dated and broke up during their time on "The Office." But they are still good friends, and Kaling said that he is more like family now.

"If I was on the outside looking at it, I would think the same thing," she told Good Housekeeping last year. "But the truth is that B.J. is so much more like family now than a platonic friend. He's the godfather to my daughter, he comes over like once a week. Sometimes he'll come over just to hang out with her."

Nina Dobrev and Ian Somerhalder
Nina Dobrev and Ian Somerhalder have been using Twitter to prove they're still friends. The exes tried to prove their friendship before at the 2014 People's Choice Awards. Reuters