Hi,
When I wanted to user playerPRefs has key action, it took me a while to figure out that it was required that a variable is set to store the result, yet the variable was not flagged as required.
so I think either it's not necessary, or else, the interface should throw an error if not set.
Here is a version that will work even if no variable is passed. I use this for just directing the flow, It's quicker than creating, and checking a variable.
// (c) Copyright HutongGames, LLC 2010-2011. All rights reserved.
using UnityEngine;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory("PlayerPrefs")]
[Tooltip("Returns true if key exists in the preferences.")]
public class PlayerPrefsHasKey : FsmStateAction
{
[RequiredField]
public FsmString key;
[UIHint(UIHint.Variable)]
[Title("Store Result")]
public FsmBool variable;
[Tooltip("Event to send if key exists.")]
public FsmEvent trueEvent;
[Tooltip("Event to send if key does not exist.")]
public FsmEvent falseEvent;
public override void Reset()
{
key = "";
}
public override void OnEnter()
{
Finish();
if( !key.IsNone && !key.Value.Equals(""))
{
variable.Value = PlayerPrefs.HasKey(key.Value);
}
Fsm.Event(variable.Value ? trueEvent : falseEvent);
}
}
}
Bye,
Jean