change z value unity

C#
 Vector3 temp = transform.position;
 temp.x = 10.0f;
 transform.position = temp;
Source

Also in C#: