My paper was accepted, but I found an error affecting all of the figures. What will happen next?
Though I don't have any prior experience with this, I agree that you should notify the editor and should explain to them how and why this mess happened. Also let then know that it was a mistake and as soon as you realized it, you let them know. Also let them know that you are ready if they want to have the paper reviewed again. I believe that they would understand the mistake and would not make a scene out of it. But yes, you have to choose your words carefully and should politely explain them the point and admit your mistake.