round vector3 unity
vector3 = new Vector3(1.23243f, 2.213124f, 12.4123f);
var roundedVector3 = vector3.Round(1); 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); } }
Also in C#:
- c# find duplicates in list of strings
- unity set object scale
- const float c#
- autoresetevent
- asp net identity add a unique fields to user
- unity onclick addlistener
- C# extend array
- get variable from another script unity
- c# web form compare dates
- how to allow user import image c#
- how to check if textbox is empty in c#
- C# get all child classes of a class
- get random value from list c#
- unity method on scene loaded
- degree between two points latitude longitude c#
- how to generate random unique id in c#
- bool toggle unity c#
- how to get specific length of row in matrix c#
- convert array object to int[] c#
- asp.netcore: develop on win10 run on ubuntu
- how to get odd saturday in a month in c#
- wait without pause anything else unity
- c# transform
- project tab unity