C# float is 0 in debug

Hi,

I have a small problem with a float value.
The value is 0, but I expect 7.32.
Probably a stupid mistake, but I didn’t find an answer.

public class GameFieldBuilder : MonoBehaviour {

    public float tileSizeX = 7.32f;

    void Start () {
        Debug.Log("A: " + 7.32f);
        Debug.Log("B: " + tileSizeX);
        Debug.Log("C: " + tileSizeX.ToString("0.0"));

Output:
A: 7.32
B: 0
C: 0.0

Thanks and best regards

your code is fine you probably set the value of tileSizeX via unity editor ,in inspector to 0.take a look at it.

or change it to

 private float tileSizeX = 7.32f;

and your problem should solve.

Yes this was the problem, thanks :slight_smile:
Didn’t know that it ignores the init value then.