Hi, I have a code like this.
text = GUI.TextField(new Rect (10, 190, 80, 20), text);
text = Regex.Replace(text, @"[^0-9 ]", "");
I convert this code from string value to int value.
int i = string.IsNullOrEmpty(text) ? 0 : int.Parse(text);
num = Convert.ToInt32(i);
The codes work fine in this way.Later,
if(Input.GetMouseButtonDown(0))
{
num -= rock;
if (num <= 0)
{
num = 0;
Debug.Log("Nice Try!");
}
}
I want the number in the text box to be reduced when I click the mouse.The problem is that only one number can be reduced.
What do I need to do to reduce it to zero?
STR İNT This is what I want.
-
1.Click ===>> [5] => [4]
-
2.Click ===>> [5] => [3]
-
3.Click ===>> [5] => [2]
-
4.Click ===>> [5] => [1]
-
5.Click ===>> [5] => [0]
STR İNT But it happens this way.
-
1.Click ===>> [5] => [4]
-
2.Click ===>> [5] => [4]
-
3.Click ===>> [5] => [4]
-
4.Click ===>> [5] => [4]
-
5.Click ===>> [5] => [4]
-
6.Click ===>> [5] => [4]
-
7.Click ===>> [5] => [4]
-
/ / /
-
/ / /
-
50.Click ===>> [5] => [4]