I am trying to make a ad pop up when the player dies/loses 3 times. I have a script made where if the collider touches the player they lose, but it is giving me these errors:
Assets/UnityAdsCounter.cs(28,62): error CS0019: Operator `>=' cannot be applied to operands of type `string' and `int'
Assets/UnityAdsCounter.cs(28,40): error CS1502: The best overloaded method match for `UnityEngine.PlayerPrefs.GetInt(string)' has some invalid arguments
Assets/UnityAdsCounter.cs(28,40): error CS1503: Argument `#1' cannot convert `object' expression to type `string'
How would I fix these and would this script work? Thanks, here is my script.
using UnityEngine;
using UnityEngine.Advertisements;
using System.Collections;
public class UnityAdsCounter : MonoBehaviour {
private int Count = 0;
private int Three = 3;
public string zoneID;
// Use this for initialization
void Awake () {
if (Advertisement.isSupported) {
Advertisement.allowPrecache = true;
Advertisement.Initialize ("40412");
string zoneName = string.IsNullOrEmpty(zoneID) ? "the default ad placement zone" : zoneID;
}
}
// Update is called once per frame
void Update () {
}
void OnCollisionEnter2D(Collision2D coll) {
if(coll.gameObject.tag == "Player"){
Count += 1;
PlayerPrefs.SetInt ("UnityAddCount", Count);
if(PlayerPrefs.GetInt ("UnityAddCount" >= Three)){
UnityAdsHelper.ShowAd(zoneID);
}
}
}
}
↧