Here is a situation from classical algebraic geometry. Let $X, Y$ be affine varieties over an algebraically closed field $\Omega$. Let $f: X \rightarrow Y$ be a morphism of varieties, corresponding to an $\Omega$-algebra homomorphism $\phi: A \rightarrow B$ of the coordinate rings. Suppose that $X, Y$ are defined over a subfield $k$ of $\Omega$. This means that there exist $k$-subalgebras $A_0, B_0$ of $A, B$ such that $A = A_0 \otimes \Omega, B = B_0 \otimes \Omega$. We say that $f$ is defined over $k$ if $\phi$ maps $A_0$ into $B_0$. Equivalently, $\phi$ comes from extending the scalars for some $k$-algebra homomorphism $\phi_0: A_0 \rightarrow B_0$. Notice that if $\phi$ is defined over $k$, then $\phi_0$ is uniquely determined.
In the modern language, this principle can be translated more generally as follows: let $X, Y$ be schemes over a given scheme $S$. Let $T$ be another $S$-scheme. We will say that a morphism of $T$-schemes $$f: X \times_S T \rightarrow Y \times_S T$$
is defined over $S$ if there exists a morphism of $S$-schemes $g: X \rightarrow Y$ such that $f = g \times 1_T$. My question is, if $f$ is defined over $S$, is the morphism $g$ uniquely determined? In other words, is the map
$$\textrm{Hom}_{\textrm{$S$-sch}}(X,Y) \rightarrow \textrm{Hom}_{\textrm{$T$}-sch}(X \times_S T, Y \times_S T)$$
$$g \mapsto g \times 1_T$$
an injection? Let's of course exclude the case where the fiber products $X \times_S T, Y \times_S T$ are the empty schemes.
I was trying to argue using the Yoneda lemma. If $g_1, g_2: X \rightarrow Y$ are $S$-schemes such that $g_1 \times 1_T = g_2 \times 1_T$, and $E$ is any $S$-scheme, then we have $g_1(E) \times 1_T(E) = g_2(E) \times 1_T(E)$ as maps
$$X(E) \times T(E) \rightarrow Y(E) \times T(E)$$
where we would then conclude $g_1(E) = g_2(E)$ for all $S$-schemes $E$, hence $g_1 = g_2$. The problem is that $T(E)$ could be empty, making the hypothesis $g_1(E) \times 1_T(E) = g_2(E) \times 1_T(E)$ useless.