The Origin of Comets in the Solar Nebula: A Unified Model