Proof (polynomial ring of UFD is UFD)
Existence of factorisation
Let $f\in R[X]$ be a non-zero non-unit polynomial. First write $f = c(f)\, \tilde f$ where $\tilde f\in R[X]$ is primitive. We can factorise $c(f) = p_1 \ldots p_n$ for $p_i \in R$ irreducible, which are also irreducible in $R[X]$. So it suffices to give factorisations for primitive polynomials $\tilde f$.
Induct on $\deg \tilde f$. If $\deg \tilde f = 0$, $\tilde f$ is a unit and so we're done. If $\tilde f$ is irreducible, we are also done. Otherwise we can write $\tilde f = g\cdot h$ where $g,h\in R[X]$ are not units. Since $\tilde f$ is primitive, $g,h$ are primitive, so neither can be constants, i.e. $\deg g, \deg h > 0$. As $R$ is an integral domain, $\deg \tilde f = \deg g + \deg h$, so $\deg g,\deg h < \deg \tilde f$. Use the induction hypothesis to factorise $g = q_1 \ldots q_m$ and $h = r_1 \ldots r_k$. We finally obtain $$ \begin{align*} f = p_1 \ldots p_n q_1 \ldots q_m r_1 \ldots r_k. \end{align*} $$
Uniqueness of factorisation
Suppose $$ \begin{align*} p_1 \ldots p_n q_1 \ldots q_m = r_1 \ldots r_k s_1 \ldots s_l \end{align*} $$ where all $p_i, q_i, r_i, s_i$ are irreducibles, $p_i,r_i\in R$ and $q_i, s_i\in R[X]$ with degree $\geq 1$.
Since $q_i, s_i$ are irreducible, they are primitive, so taking content on both sides, $$ \begin{align*} p_1 \ldots p_n = u\cdot r_1 \ldots r_k \end{align*} $$ for some unit $u\in R$. Then by unique factorisation in $R$, $n=k$ and $p_i$ and $q_i$ are associates up to reordering.
Now we have $$ \begin{align*} u\cdot q_1 \ldots q_m = s_1 \ldots s_l, \end{align*} $$ with both sides primitive. Viewing in $F[X]$ where $F$ is the field of fractions of $R$, since $F[X]$ is a Euclidean domain and thus unique factorisation domain, we have $m=l$ and up to reordering, $q_i$ and $s_i$ are associates in $F[X]$. This means $q_i \mid s_i$ and $s_i \mid q_i$ in $F[X]$, but since $q_i$ and $s_i$ are primitive, this is equivalent to $q_i \mid s_i$ and $s_i \mid q_i$ in $R[X]$. Thus $q_i$ and $s_i$ are associates in $R[X]$.