PlayerPrefs does not contain a definition for 'SetInt'

Hi,

I am quite new at this but I can’t seem to set an int to the playerprefs. I am using C#. The script uses MonoBehaviour.

In a OnTriggerEnter function i use the following. I’ve tried the official unity manual examples but I keep getting the same error. PlayerPrefs does not contain a definition for ‘SetInt’. Why doesn’t it recognize the SetInt (or SetFloat and so on for that matter).

PlayerPrefs.SetInt(“crates”, 10);

Thanks a bunch!

The problem was that the scriptname and thus the class name was PlayerPrefs. I think a face palm is in order. It was driving me crazy with not even a single Google hit on the literal Unity error. Thanks again, you guys rock!

Solution for the Noobs: rename you own class to PlayerPrefsX (and keep on learning)

p.s. Can, and should, I somewhere put this question to “solved”?

Maybe you removed “using UnityEngine;” from the top the the file? or defined class PlayerPrefs in your own source?