Join our Discord Channel
Total Members Voted: 1
// (c) Copyright HutongGames, LLC 2010-2011. All rights reserved.using UnityEngine;namespace HutongGames.PlayMaker.Actions{ [ActionCategory(ActionCategory.Convert)] [Tooltip("Converts a Float value to a String value.")] public class ConvertFloatToString : FsmStateAction { [RequiredField] [UIHint(UIHint.Variable)] public FsmFloat floatVariable; [RequiredField] [UIHint(UIHint.Variable)] public FsmString stringVariable; public FsmInt numberOfDecimalPlaces; public bool everyFrame; public override void Reset () { floatVariable = null; stringVariable = null; numberOfDecimalPlaces = 2; everyFrame = false; } public override void OnEnter() { DoConvertFloatToString(); if (!everyFrame) Finish(); } public override void OnUpdate() { DoConvertFloatToString(); } void DoConvertFloatToString () { numberOfDecimalPlaces.Value = (numberOfDecimalPlaces.Value < 0) ? 0 : numberOfDecimalPlaces.Value; // doesn't allow negative numbers stringVariable.Value = floatVariable.Value.ToString ("F" + numberOfDecimalPlaces.Value); } }}