Usually, if I store a vector and intend to use its components separately I’ll store it in one variable.
Vector3 terrainSize = terrain.terrainData.size;
//Check if terrain size is uniform
if (terrainSize.x != terrainSize.z)
{
Debug.LogErrorFormat(this.name + ": size of \"{0}\" is not inform at {1}!", terrain.name, terrainSize.x + "x" + terrainSize.z);
this.enabled = false;
}
float terrainSizeX = terrain.terrainData.size.x;
float terrainSizeZ = terrain.terrainData.size.z;
//Check if terrain size is uniform
if (terrainSizeX != terrainSizeZ)
{
Debug.LogErrorFormat(this.name + ": size of \"{0}\" is not inform at {1}!", terrain.name, terrainSizeX + "x" + terrainSizeZ);
this.enabled = false;
}
Both methods will work, I suppose it’s a matter of preference and/or readability
Both of the examples you are showing are declaring 3 variables named x, y, and z. The only difference is syntax. I personally tend to use the second syntax because to me it’s easier to read. But it just comes down to preference, or if working with a team whatever coding standards are agreed upon.