I have been messing with this for way to long, I’m not sure what the deal is maybe someone can help. Here is my script:
var CurrentXP : int;
var SaveCurrentXP : int;
function Start ()
{
CurrentXP = PlayerPrefs.GetInt("Current XP");
}
function Update ()
{
SaveCurrentXP = CurrentXP;
CurrentXP += 1;
if (Input.GetKeyDown(KeyCode.P))
{
Debug.Log("Current XP: " + CurrentXP + "." + "Saving Current XP");
PlayerPrefs.SetInt("CurrentXP", SaveCurrentXP);
}
}
function OnDisbale()
{
PlayerPrefs.SetInt("Current XP", SaveCurrentXP);
}
Basically for testing purposes I want it to save and load an integer. this interger changes every second, and I can press “P” to save it, also pressing P prints it in the log so I know that its working.
However when I start the game in the editor, I am presented with this error:
MissingMethodException: PlayerPrefs.SetInt
Boo.Lang.Runtime.DynamicDispatching.MethodDispatcherFactory.ProduceExtensionDispatcher ()
Boo.Lang.Runtime.DynamicDispatching.MethodDispatcherFactory.Create ()
Boo.Lang.Runtime.RuntimeServices.DoCreateMethodDispatcher (System.Object target, System.Type targetType, System.String name, System.Object[] args)
Boo.Lang.Runtime.RuntimeServices.CreateMethodDispatcher (System.Object target, System.String name, System.Object[] args)
Boo.Lang.Runtime.RuntimeServices+<Invoke>c__AnonStorey14.<>m__7 ()
Boo.Lang.Runtime.DynamicDispatching.DispatcherCache.Get (Boo.Lang.Runtime.DynamicDispatching.DispatcherKey key, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory)
Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.String cacheKeyName, System.Type[] cacheKeyTypes, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory)
Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.Object[] args, System.String cacheKeyName, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory)
Boo.Lang.Runtime.RuntimeServices.Invoke (System.Object target, System.String name, System.Object[] args)
UnityScript.Lang.UnityRuntimeServices.Invoke (System.Object target, System.String name, System.Object[] args, System.Type scriptBaseType)
PlayerPrefs.Start () (at Assets/Scripts/JavaScript/PlayerPrefs.js:6)
I’ve tried researching this problem and cannot find anything.
I have successfully used PlayerPrefs in C# (I’m using javascript this time around) on a game I made a while ago. I am looking at it as a reference and nothing is helping.
Any help is greatly appreciated.
Thanks!