- Home /
This question was
closed Feb 23, 2019 at 01:46 PM by
panim0_unity for the following reason:
Solved this myself!
Question by
panim0_unity · Feb 23, 2019 at 01:04 PM ·
c#uitextplayerprefspoints
PlayerPrefs, it doesn't change the text after restarting the game
Here's my code, on click it shows an ad and adds point but when i restart it the text which shows points resets and I dont know why.
public Text points;
public static int points1;
public Button[] watchbutton;
void Start()
{
PlayerPrefs.GetInt("ScoreCmon");
points.text = "Points: " + points1.ToString();
}
void Update()
{
points.text = "Points: " + points1.ToString();
}
public void watch()
{
if (UnityEngine.Advertisements.Advertisement.IsReady())
{
watchbutton[0].interactable = true;
UnityEngine.Advertisements.Advertisement.Show("rewardedVideo", new ShowOptions() { resultCallback = HandleAdResult });
}
else {
watchbutton[0].interactable = false;
watchbutton[0].image.color = Color.red;
}
}
private void HandleAdResult(ShowResult result)
{
switch (result)
{
case ShowResult.Finished:
points1 += 100;
PlayerPrefs.SetInt("ScoreCmon",points1);
break;
case ShowResult.Skipped:
break;
case ShowResult.Failed:
break;
}
}
Comment
Follow this Question
Related Questions
shop script not working 1 Answer
UI text color not assigning correctly 2 Answers
Text UI broken after changing alpha color of single letters 1 Answer
PlayerPrefs issue 2 Answers