(Note: The original question had an incorrect premise.  The ideal generated by elements of positive degree in an arbitrary graded ring is not generally maximal.)

Let $R=\mathbb{Z}+x\mathbb{Q}[x]$.  This is an $\mathbb{N}$-graded ring, where  grade-$0$ is $\mathbb{Z}$, and grade-$n$ with $n\geq 1$ is $\mathbb{Q}x^n$.

This ring is is not a UFD, since $x=2(2^{-1}x)=2^2(2^{-2}x)=\cdots$ shows that $x$ is infinitely divisibly by the irreducible element $2$.

Letting $\mathfrak{m}$ be the ideal generated by all elements of positive grade, then $R_{\mathfrak{m}}\cong \mathbb{Q}[x]$, which is a UFD.

-----

To address the modified question:  If $R_0$ is a field, then $R=R_{\mathfrak{m}}$.  So of course, $R$ is a UFD if and only if $R_{\mathfrak{m}}$ is.