Necessary and sufficient conditions for unit graphs to be Hamiltonian