2. Given that $a, b, c$ satisfy
$$
\begin{array}{l}
|2 a-4|+|b+2|+\sqrt{(a-3) b^{2}}+a^{2}+c^{2} \\
=2+2 a c .
\end{array}
$$

Then the value of $a-b+c$ is ( ).
(A) 4
(B) 6
(C) 8
(D) 4 or 8
2.D.

When $b=0$, the original equation becomes
$$
|2 a-4|+(a-c)^{2}=0 \text {. }
$$

Solving this, we get $a=c=2$.
Therefore, $a-b+c=4$.
When $b \neq 0$, $b^{2}>0, a \geqslant 3$.
Thus, $2 a-4 \geqslant 2$.
The original equation becomes
$$
2 a-4+|b+2|+\sqrt{(a-3) b^{2}}+(a-c)^{2}=2 \text {, }
$$

which simplifies to
$$
|b+2|+\sqrt{(a-3) b^{2}}+(a-c)^{2}=6-2 a \text { . }
$$
Thus, $6-2 a \geqslant 0$, which means $a \leqslant 3$.
Therefore, $a=3$.
Then, $|b+2|+(3-c)^{2}=0$.
Solving this, we get $b=-2, c=3$.
Therefore, $a-b+c=3-(-2)+3=8$.