Yaptıgım kodda başka bir script'teki koda erişip ordaki bir değeri if kullanarak belli bir rakamın üstünde ise bazı işlemler yaptırmak istiyorum. Sonra diğer script'teki kodu azaltıyorum ama o değer bir türlü kaydedemiyorum.
Kod:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class Level : MonoBehaviour
{
public Text skortxt;
public int skor = 0;
public int Altintopla = 0;
public int puan;
public int kazanilan;
public int puandeger = 0;
void Start()
{
puandeger = PlayerPrefs.GetInt("puan");
skor = PlayerPrefs.GetInt("altin");
}
public void OnTriggerEnter(Collider KUTU)
{
if(KUTU.gameObject.tag=="KUTU")
{
kazanilan +=10;
PlayerPrefs.SetInt("puan",(puan+kazanilan));
}
}
public void Update ()
{
puan = (PlayerPrefs.GetInt("puan"));
}
public void altinile()
{
if (skor > 20)
{
skor -= 20;
kazanilan += 100;
PlayerPrefs.SetInt("puan", (puan + kazanilan));
PlayerPrefs.SetInt("skor", (skor -20));
}
}
}
Son düzenleyen: Moderatör: