- Home /
Question by
andrer11444 · Feb 08, 2021 at 11:52 AM ·
inspectorvalue
Is the inspector Value accessable?
Hello
Ill try to simplify my question, cus i got no answere til today.
I have an Image what says Level 1.
On this Image i attached a very simple script:
CurrentLevel: Monobehvior {
public int currentLevel;
}
Thats it.
Now in the Inspector i can change it to 1. I attached this script to all the other levelImages. And therefore changed each currentLevel to 2...3 and so on.
Now in another script i want to compare this valur with a player.pref value to check if the currentlevel is finished.
But the other script cant find the values i put into the inspector.
Why is that? Is the inspector not saving the value in currentLevel?
is there another way to solve this?
Thank you
Comment
Answer by DiasPTW · Feb 08, 2021 at 12:05 PM
You could try something like
int CurrentLevel;
private void Start(){
CurrentLevel = FindObjectOfType<CurrentLevel>().currentLevel;
if(PlayerPrefs.GetInt("[Name]") == CurrentLevel){
[DoStuff]
}
}