Hello! I have made so when I pickup the weapon, I unlock an Image (Set Active) and that’s working.
But now I want to save it in PlayerPrefs, how could I do it?
My Pickup Script:
public class WeaponPickUp : MonoBehaviour
{
public string weaponName;
public static Image unlockImage; // This is the Image
private void Awake()
{
// Find the Weapon Name and Unlock Text
unlockImage = GameObject.Find(weaponName + " " + "Unlock").GetComponent<Image>();
}
private void OnTriggerStay(Collider other)
{
if (other.tag == "Player")
{
if (Input.GetKeyDown(KeyCode.E))
{
// Remove the Unlock Image
unlockImage.GetComponent<Image>().gameObject.SetActive(false);
Destroy(gameObject, 1.5f);
}
}
}
}
I’m not sure how to save PlayerPrefs with bools, I have find some solutions but it’s not working.