unity vector3.round code example

Example 1: unity round vector 3 to nearest integer

//Converts a Vector3 to a Vector3Int by doing a Round to each value.
Vector3Int.RoundToInt(Vector3)

Example 2: round vector3 unity

static class ExtensionMethods {     /// <summary>     /// Rounds Vector3.     /// </summary>     /// <param name="vector3"></param>     /// <param name="decimalPlaces"></param>     /// <returns></returns>     public static Vector3 Round(this Vector3 vector3, int decimalPlaces = 2)     {         float multiplier = 1;         for (int i = 0; i < decimalPlaces; i++)         {             multiplier *= 10f;         }         return new Vector3(             Mathf.Round(vector3.x * multiplier) / multiplier,             Mathf.Round(vector3.y * multiplier) / multiplier,             Mathf.Round(vector3.z * multiplier) / multiplier);     } }