- Home /
The question is answered, right answer was accepted
Changing values of a script from another script not showing in game
The problem i am curently facing is that i am changing variables of a script from another script and i am not able to see those variables change in game.If i exit the game and start the game again i see them change but this should not happend.
here is my code:
if(Exp >= 100)
{
LevelUP = true;
GameManager.Level ++;
GameManager.SkillPoints ++;
}
in the other script the level and skill points are just decleared as public and are shown in game via OnGUI so they are updated like they should.
i think this is some sort of bug because this used to work
Are you using static variables ? Are you also using multiple scenes and is your game $$anonymous$$anager resetting correctly. Consider tracing through Debug at various points in your code where value is affected and carried over.
they are all decleared public int Level;public int SkillPoints; i think they dont reset corectly as before i seen them update in inspector after i stoped the game and when it started it started with the values it should have had when i closed the game
then try using 'static' keyword for your variable declarations. Check if it has the right effect.
i cannot change them from the other script if i eclare them as static
Follow this Question
Related Questions
Error ambiguous reference with Json 1 Answer
3D Gravity towards one object 3 Answers
How to Load from an external file, sound 0 Answers
Distribute terrain in zones 3 Answers
Clamping a Manipulated Camera 0 Answers