playMaker

Author Topic: ConvertStringToFloat.cs  (Read 1202 times)

maart

  • Playmaker Newbie
  • *
  • Posts: 45
    • View Profile
ConvertStringToFloat.cs
« on: January 02, 2013, 03:52:07 AM »
Code: [Select]
// (c) Copyright HutongGames, LLC 2010-2011. All rights reserved.

using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Convert)]
[Tooltip("Converts an String value to an float value.")]
public class ConvertStringToFloat : FsmStateAction
{
[RequiredField]
[UIHint(UIHint.Variable)]
public FsmString stringVariable;

[RequiredField]
[UIHint(UIHint.Variable)]
public FsmFloat floatVariable;

public bool everyFrame;

public override void Reset()
{
floatVariable = null;
stringVariable = null;
everyFrame = false;
}

public override void OnEnter()
{
DoConvertStringToFloat();

if (!everyFrame)
Finish();
}

public override void OnUpdate()
{
DoConvertStringToFloat();
}

void DoConvertStringToFloat()
{
floatVariable.Value = float.Parse(stringVariable.Value);
}
}
}
« Last Edit: January 02, 2013, 04:24:40 AM by maart »