string RounderA = RaycastHit.distance.ToString();
RounderA = string.Format(“{0:0.##}”, RounderA);
tmA.text = RounderA;
Ignores my string.format
i want to set raycasthit.distance to show only 2 decimal
0.02 isted he is showing 0.023345354
string RounderA = RaycastHit.distance.ToString();
RounderA = string.Format(“{0:0.##}”, RounderA);
tmA.text = RounderA;
Ignores my string.format
i want to set raycasthit.distance to show only 2 decimal
0.02 isted he is showing 0.023345354
The problem is you don’t feed the float value into string.Format. You pass it already as string and a string isn’t formatted but simply copied to the result.
either use:
string RounderA = string.Format("{0:0.##}", RaycastHit.distance);
tmA.text = RounderA;
or
string RounderA = RaycastHit.distance.ToString("0.00");
tmA.text = RounderA;