Pixar's iconic "Toy Story" might never have happened if not for help from future "Avengers" writer and director Joss Whedon.

Based on original Pixar short "Tin Toy," an early rough draft of "Toy Story" was a disaster.

Here's how it was described by Amy Pascale in the recent "Joss Whedon: The Biography": [T]he movie was unwatchable. The story had lost the heart that Tin Toy had; the leads, Woody the cowboy and Buzz Lightyear the astronaut, were sarcastic and unlikeable—not exactly ideal heroes for a children’s movie." Notably, the lead character of cowboy Woody was "a bitter toy who berated and insulted all the other toys and was bound and determined to destroy Buzz."

It wasn’t until Whedon, who had recently created "Buffy the Vampire Slayer," was asked to step in and help refocus the entire script that the film started to look more like the version of "Toy Story" we know.

"They sent me the script and it was a shambles," Whedon recalled in "Joss Whedon: Conversations." "But the story that [John] Lasseter had come up with was, you know, the toys are alive and they conflict. The concept was gold."

What was originally planned to be a three-week job turned into more than six months of working with Pixar.

One big decision was whether or not the movie should be a musical like recent Disney hits such as "The Little Mermaid," "The Lion King," and "Beauty and the Beast." Whedon, like Pixar head John Lasseter, decided that wasn’t a good idea.

“It would have been a really bad musical, because it’s a buddy movie,” Whedon told Entertainment Weekly. “It’s about people who won’t admit what they want, much less sing about it. Woody can't do an 'I want' number--he's cynical and selfish, he doesn't know himself. Buddy movies are about sublimating, punching an arm, 'I hate you.' It's not about open emotion."

One of Whedon's biggest contributions was an insight about astronaut Buzz, according to Pascale:

Joss worked closely with Pixar’s team as everyone got their heads around the idea of Toy Story as a buddy picture. Buzz Lightyear had always been conceived as a Dudley Do-Right: dim-witted but cheerful and self-aware. Joss helped them reenvision the character as an action figure who isn’t aware that he’s a toy, and who therefore takes his job as an Intergalactic Space Ranger quite seriously. It was a huge epiphany that turned the whole movie around and created the chemistry in Toy Story.

Joss Whedon helped reenvision the character of Buzz Lightyear as a toy who isn't aware he's a toy. Disney / Pixar

One Whedon change that didn't make the final cut involved Mattel's Barbie. According to EW, the writer, known for strong female characters, wanted the doll to swoop in and save both Woody and Buzz from the film's antagonist, Sid. However, Mattel wouldn't give permission for Barbie to appear.

The animated movie was finally given the greenlight to be filmed in April 1994 and after several more rewrites with Whedon, the film became the first full-length computer animated movie, ushering in a new age for other animated pictures.

"Toy Story" went on to make $361.9 million at the box office and was nominated for three Oscars.

Subsequent sequels performed even better at theaters, with 2010’s “Toy Story 3” grossing over $1 billion worldwide.