playerpreferance.setint problem
I am develop one game.In this game 15 levels. I am face this type of issues when send one level score into second levels. I am used player preferences in start() method. Get after Increase the score 20% levels. Player will be given score when the levels finished success.
how to score get used preferences in next level??
Math: Level 1 would be 20 + 0 Level 2 is 20 + (20), Level 3 is 20 + (40), Level 4 is 20 + (60), Etc. ex:
Scene1-> Level1(finishlevel) -> Getclaim button press currentreward=20;
Scene2->Level2(finishlevel)-> Getclaim button press currentreward=40;
Code:
GameManager.cs
int pointAdd;
public int levelID; //ex: Leve1 levelId=0 ,Level2 Leveld=1
public Text creditsText;
void FixUpdate()
{
creditsText.text="" + PlayerPrefs.GetInt("", 0).ToString();
}
public void GetClaim()
{
pointAdd = PlayerPrefs.GetInt("",0);
pointAdd = 20 + (levelID * 20); //FIRST SCENE LEVEID=0 //SecondScene LevelId =1 ////problem here when i m quit a game not increment 20,game store only 20
PlayerPrefs.SetInt("", pointAdd);
creditsText.text = ("" + pointAdd);
btnreward.SetActive(false); //one time claim then deactive button
}
what i m doing: playing a game when i m play level1=20,level2=40 preferance store.that run successful but when i m quit a game and again play a game(means level1)current credittextis=40 but not add a 20 means my credittext is=60,but game can store here Credittext=20??
Start()
is called in this chain? This may clarify how you expect this to work, versus what's actually happening. \$\endgroup\$