This is how Unicron's defeat and Optimus and Twilight lose their memories goes in episode 26 of season 1 of Ryan F-Freeman's Adventures of Transformers: Prime.
Optimus Prime: Matrix of Leadership, I call upon you.
Twilight Sparkle: Magic of the Alicorn come to me.
Ryan F-Freeman: Master Eraqus. Primus. Give me the power that I need.
[Ryan and 2 of his friends power up]
Unicron: You cannot defeat me, disciple of Primus, Princess of Friendship, and student of Primus. I have transcended physical being. By my will alone, all upon this world shall fall into chaos.
Optimus Prime: Not while I still function, Unicron. The power of the Matrix will light our darkest hour.
Twilight Sparkle: Lead you down the path of Friendship.
Ryan F-Freeman: And light the road of recovery.
[Ryan uses his Keyblade, Optimus uses the Matrix, and Twilight uses the Magic of the Alicorn on Unicron]
Ryan F-Freeman: Whoa. My head.[falls on the floor]
[Everything returns to normal]
Megatron: Teamwork? Ha.
[Megatron approaches the two, sword drawn]
Optimus Prime: Where are we, Megatronus?
Twilight Sparkle: And what happened?
Megatron: Don't you remember, old friends?
Ryan F-Freeman: [feels dizzy] I remember the 13 original Primes and Alicorns.
Bulkhead: Optimus, you alright?
Applejack: You okay, Twi?
Optimus Prime: Why did he call me that?
Twilight Sparkle: And why did she call me Twi?
Arcee: What did you do to them?
Rainbow Dash: Yeah.
Twilight Sparkle: Who are they?
[Decepticon Groundbridge appears]
Megatron: Our mortal enemies. We're outnumbered. Go, I'll cover you.
[Before entering the Groundbridge, Optimus and Twilight look back at Bumblebee and Rarity. Bee bleeps something and Rarity just stares wide-eyed. Optimus and Twilight then go into the Groundbridge]
[After a short battle with them, Megatron enters the groundbridge. Ratchet bridges the team back and they have a little conversation]
Ratchet: Optimus and Twilight. Are they...?
Arcee: Dead? No.
Bulkhead: But they looked right at us without recognizing us. Didn't even know their own names.
Ratchet: If Twilight and Optimus did not know their own names, they lost more than just the collectable wisdom of the Primes and Alicorns. They lost their own memories.
Ryan F-Freeman: Not me. I saved our home.
Ratchet: True, Ryan. But we have already lost two great leaders.
Crash Bandicoot: Congrats, Ryan. Until Optimus and Twilight come back, You and I will be the Autobots' new leaders.
[The Autobots cheer]
Ryan F-Freeman: Thanks. What will my and Crash's Prime names be?
Ratchet: Not sure but we may figure it out in the future.
Arcee: Well, Thomas, good luck trying to get your girlfriend back. [realizes he's gone] Thomas?
Bulkhead: He's gone.
Evil Ryan: Holy cow.
Rainbow Dash: And you didn't believe him.
Ryan F-Freeman: Wait. I think... I got Optimus' and Twilight's memories in me.
Sunset Shimmer: Really?
Ryan F-Freeman: Yes. I think it's when I use the magic from my Keyblade, some of it's magic must have transferred their memories to me.
Ratchet: You mean you got the collectable wisdom of the Primes and Alicorns and both Twilight's and Optimus' memories in your head, Ryan?
Ryan F-Freeman: I don't know why. But wherever Thomas is, I hope he's okay.
Evil Ryan: Yeah. You remember what Twilight learned, Ryan?
Ryan F-Freeman: Yeah. And also what Optimus learned.
Matau T. Monkey: You do? How you got both their memories in your head, Master Ryan?
Ryan F-Freeman: Not sure.
Crash Bandicoot: I hope we will get them back someday.
Bertram T. Monkey: We will, Bandicus Prime. We will.
Rainbow Dash: Yeah.
Matau T. Monkey: Yeah. And when they return, we will tell Prime and Twilight about what did Master Ryan learn. Maybe someday, someone by the name of Odette needs our help.
Knock Out: Welcome back, Lord Megatron.
Breakdown: [sees Optimus and Twilight and charges]
Megatron: At ease, Breakdown. That is no way to welcome long lost comrades. Orion Pax and Nightfall Twinkle are one of us.
[To be continued...]