Additionally, I can say that the variables look like this:
[SerializeField] Text value1Text;
[SerializeField] int value1;
[SerializeField] Text value1Text;
[SerializeField] int value2;
void Start()
{
value1Text.text = value1.ToString();
value2Text.text = value2.ToString();
}
The values are added as shown in the Inspector directory, but after reaching the value of 3, the code is not executed. I also tried changing the operators greater than equal, but it did not give any result.
Those values appear private to me. How is the other script getting those variables? Just declaring them in the other script simply makes brand new ones, even if they’re the same name.
@Kurt-Dekker ,
When this function was used, the values stopped increasing.
Yes, I know that, I tried to combine them, but for that I would have to use static values and that causes a lot of complications. So I created two new ones referenced by the same objects in Unity. However, objects added to the second script are not visible, even when ‘public’ is used.
I kinda got tired of handling this sorta multi-script scattered data hassle all over the place noise, so I wrote a package I call Datasacks and put it out for free. It’s overkill in your case, but Datasacks are a handy way to interoperate with data from any arbitrary scene or code or chunk of UI.
I considered making a mistake in the code. However, the code was written correctly, and it works with a different condition. When: ‘value <= 3’, Unity sees the value and the code is executed. In the case of ‘value == 3’, it is as if Unity was omitting this value.
value1 and value2 are simply not reaching 3, or your check is happening in part of the script that does not get executed when they happen to reach 3.
How are these values (value1 and value2) expected to change? Being private, only a function in the same script could be modifying value1/2. Post your whole script.
I did as you said and you were right about the increase in value. However, the condition continued to become a problem.
In the script, I use two relating to these variables, one works fine, the other which I have already mentioned here does not. Why?
First relating: (What is strange !! When I was using || as or acted as and. The condition uses && as and and works like or.)