Hi, I am trying to use PlayerPrefbs to store an int and value and then show that value on a UI text. But I get 2 errors. The first one is error CS7036: There is no argument given that corresponds to the required formal parameter ‘value’ of ‘PlayerPrefs.SetInt(string, int)’ and the second one is error CS0023: Operator ‘.’ cannot be applied to operand of type ‘void’.
Here is the code, I hope you can help me.
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class CashManagement : MonoBehaviour
{
public int InitialCash = 10;
public int ItemPrice;
public Text ShowCash;
void Start()
{
PlayerPrefs.SetInt("PlayerCash", InitialCash);
ShowCash.text=PlayerPrefs.SetInt("PlayerCash");
}
public void BuyItem(){
int ActualCash = PlayerPrefs.GetInt("PlayerCash");
int NewCash;
if(ActualCash>=ItemPrice){
NewCash = ActualCash-ItemPrice;
PlayerPrefs.SetInt("PlayerCash", NewCash);
ShowCash.text=PlayerPrefs.SetInt("PlayerCash").ToString();
}
}
}