Answer the question
In order to leave comments, you need to log in
How can I make sure that the value of "money" is saved when restarting the game?
Here is the script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Advertisements;
using UnityEngine.UI;
public class UnityAds : MonoBehaviour, IUnityAdsListener
{
string placement = "rewardedVideo";
public float money;
public Text moneyTxt;
void Start()
{
Advertisement.AddListener(this);
Advertisement.Initialize("4037106", true);
}
public void OnUnityAdsDidFinish(string placementId, ShowResult showResult)
{
if (showResult == ShowResult.Finished)
{
moneyTxt.text = "Money:" + money++;
}
else if (showResult == ShowResult.Failed)
{
//On no!
}
}
public void OnUnityAdsDidStart(string placementId)
{
}
public void OnUnityAdsReady(string placementId)
{
}
public void OnUnityAdsDidError(string message)
{
}
public void ShowUnityAD(string p)
{
Advertisement.Show(p);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question