For his new YouTube Red series, “Ryan Hansen Solves Crimes on Television,” Rawson Marshall Thurber wears a whole lot of hats: creator, writer, director and showrunner. The show, made exclusively for YouTube’s premium subscription channel, parodies “Law and Order”-type shows and stars Ryan Hansen alongside Samira Wiley as totally opposite but bizarrely compatible partners in crime.

Thurber generated the idea for the show during the filming of his last movie, “Central Intelligence,” which starred Dwayne Johnson and Kevin Hart – and Ryan Hansen in a small role. Thurber had been a long-time fan of Hansen, so when the film’s producer Beau Bauman (who also executive produces “Ryan Hansen Solves Crimes on Television”) suggested they get him to play an office jerk in “Central Intelligence,” Thurber was ecstatic. “I just about spit out my coffee,” he tells Variety. “And I wasn’t even drinking any!”

Hansen agreed to play the role and impressed the cast and crew during the mere two days he was onset. “Ryan was so funny that he made Kevin laugh. It was the first and only time that I saw Kevin Hart break in a scene,” Thurber recalls. “I remember standing at the monitors with Beau, who said, ‘We need to get Ryan on a TV show or something.’ And I said, ‘I think we’ve gotta write a show for him.’ That’s how good he is.”

Each episode of “Ryan Hansen Solves Crimes on Television” is inspired by “some inane Los Angeles banality that drives me crazy,” says Thurber, who has lived in the City of Angels for half of his life.

“We have an episode where Ryan and Samira are stuck in traffic on a Tuesday at 11 in the morning. The entire episode is them trying to get three miles across town,” he explains. “We combine that with some tried and true procedural tropes. Every episode starts with one more dead body than the previous episode. We make those jokes in homage. It’s a strange love letter to Los Angeles and procedural television.”

The creative license granted by YouTube Red has led Thurber to proclaim this project as “one of the best filmmaking experiences of my life.”

“I couldn’t imagine a better venue for our particular show. Because YouTube Red is such a new platform, you’re making a show for an audience that might not quite be there yet. You’re right on the frontier of something, which is a challenge, but also really exciting,” Thurber says. “The pros were nearly complete creative freedom and total support, which is all you can ask for. We didn’t have all the money in the world, but we had enough to get done what we needed to get done.”

And Thurber notes that sometimes those budgetary restrictions can actually be a “blessing in disguise” anyway because it forces the writers to get more creative.

Hansen has worked with emerging streaming platforms in the past – namely CW Seed when he starred in the digital “Veronica Mars” spinoff “Play It Again, Dick” – and notes that in those environments you really get to “do [your] own thing.” He acknowledges that YouTube Red, specifically, had “great input and a great sense of humor about themselves,” which lent itself to meta jokes within the show about the platform.

In fact, the show could not exist without all players having a good sense of humor about themselves. “Playing a cartoon character of myself is always really fun. Rawson Marshall Thurber wrote this script and was like, ‘Don’t take offense when you read this. It’s all in good humor.’ I read it and I fell in love with it.” Hansen says. “I have such faith in Rawson and Beau Bauman, so I knew I was in good hands even when I was making fun of myself.”

Thurber says that one his favorite examples of that kind of self-referential comedy on set was when they were first on the sitcom set, which is Ryan’s “house” on the show. “We shot the scene with a live studio audience, which was fun because they didn’t know anything about the show. They were in the stands like a real studio audience,” Thurber says. “We did our scene for the first time and the audience started laughing and clapping like a studio audience would. That was after the first take. The audience was laughing like it was a real sitcom. It was a very meta moment for us.”

In addition to the script of self-aware comedy, the undeniable chemistry between Hansen and Wiley anchors the show. While Hansen and Wiley’s characters do not hit it off quite so immediately – Wiley plays a serious law enforcement professional who doesn’t enjoy having an actor tag along to crime scenes – Hansen says that working with Wiley was the greatest gift of all.

“When I signed on to do this, we didn’t have her part filled until two or three days before shooting. When I found out we got Samira, I was so excited and nervous because she’s such a bada–,” Hansen says. “She’s a Julliard-trained, Emmy-nominated actress. She’s legit and, well, I’m a comedic theater-trained actor, so I was super pumped to be able to work with her. Turns out, we really like each other and love each other and have so much fun. I’m sure it felt good for her to work with me as well, you know, it always feels good to give back.”

Wiley, who was excited to work on a more lighthearted show after starring on dramas like “The Handmaid’s Tale” and “Orange is the New Black,” expressed a mutual respect and admiration for Hansen. “The chemistry that Ryan and I have is something that I don’t want to take for granted. It was really magical,” she says. “We hadn’t met each other at all before the first day on set. Now, not only do I feel like we made something awesome together, but I feel like he’ll be my friend for a really long time.”

“Ryan Hansen Solves Crimes on Television” is now streaming on YouTube Red.