When using the below it gives me a key/value pair same as using PlayerPrefs, but instead of it being a specific variable it's FsmVar so you can select what variable type you want. Now this works for sending variables to an action, but it doesn't work for setting them.
[CompoundArray("Store Variables", "Key", "Value")]
public FsmString[] storeKeys;
[UIHint(UIHint.Variable)]
public FsmVar[] storeVariables;
The chunk of code below is from one of my CoherentUI actions.
Dictionary<string, object> setEventCalled( Dictionary<string, Coherent.UI.Binding.Value> options ) {
Dictionary<string, int> index = new Dictionary<string, int>();
if ( storeKeys.Length > 0 ) for ( int i = 0; i < storeKeys.Length; i++ ) {
if ( ( ! storeKeys[i].IsNone ) && ( storeKeys[i].Value != "" ) ) {
index.Add( storeKeys[i].Value, i );
}
}
if ( options.Count > 0 ) foreach ( var option in options ) {
int i;
if ( index.TryGetValue( option.Key, out i ) ) {
if ( option.Value.Type.Equals( Coherent.UI.Binding.ValueType.UInteger ) ) {
storeVariables[i].intValue = (int) (uint) option.Value;
} else if ( option.Value.Type.Equals( Coherent.UI.Binding.ValueType.Integer ) ) {
storeVariables[i].intValue = option.Value;
} else if ( option.Value.Type.Equals( Coherent.UI.Binding.ValueType.Boolean ) ) {
storeVariables[i].boolValue = option.Value;
} else if ( option.Value.Type.Equals( Coherent.UI.Binding.ValueType.String ) ) {
storeVariables[i].stringValue = option.Value;
} else if ( option.Value.Type.Equals( Coherent.UI.Binding.ValueType.Number ) ) {
storeVariables[i].floatValue = option.Value;
}
}
}
return getEventCalled();
}
As there is no FsmVar.Value I used "FsmVar.stringValue" for example. So a below example as follows.
FsmVar.stringValue = "Pass";
The above doesn't appear to work. Any idea why? Is it due to using the CompoundArray or do FsmVars just not support setting?