playMaker

Author Topic: Checking PlayerPrefs (Refreshing a fsm?)  (Read 1637 times)

adamrobertson

  • Playmaker Newbie
  • *
  • Posts: 9
Checking PlayerPrefs (Refreshing a fsm?)
« on: September 16, 2013, 03:07:56 PM »
Hi Everyone,

I have a script i made before i started using playmaker and am trying to combine the 2 together but having a problem.

I add a value to a playpref within the script and then use playmaker to check if the value is there and if it is load the next section.

The problem is that it is not loading the next scene until i stop the test and restart it.

Is there any way to refresh a state so the the fsm can realise the playerpref is updated?

Below is where i add the playerpref value

----------

 void OnGUI()
    {
        GUILayout.BeginVertical();
       
        if (solved == placedWords.Count)
        {
         PlayerPrefs.SetInt("GameComplete",1);
            GUI.Box(new Rect((Screen.width / 2) - 100, (Screen.height / 2) - 15, 200, 30), "Solved!");
            GUILayout.BeginHorizontal();
            GUILayout.Label("Time ");
            GUILayout.Label(FinalTime());
           
        }

---------

Any help would be great.

Thanks,

Adam

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Checking PlayerPrefs (Refreshing a fsm?)
« Reply #1 on: September 17, 2013, 02:54:08 AM »
Hi,

you should implement a mechanism to fire a global event from your script. Reading PlayerPref is expensive and should be done as regularly, it's only a way to store data to persits, not something to work with during your game per say, instead maintain a variable that mirror the value you expect and have a fsm that on specific user action save/read into the playerpref ( like when exiting the menu or in specific context, like the end of a level or a pause or some sort).

bye,

 Jean