Hi,
to complement StringDeleteLine, you can get the number of lines in a string.
// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved.
using UnityEngine;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.String)]
[Tooltip("Get the number of lines of a string.")]
public class StringGetLineCount : FsmStateAction
{
[Tooltip("The string.")]
[RequiredField]
[UIHint(UIHint.Variable)]
public FsmString theString;
[Tooltip("The number of lines")]
[RequiredField]
[UIHint(UIHint.Variable)]
public FsmInt lineCount;
public override void Reset()
{
theString = null;
lineCount = 0;
}
public override void OnEnter()
{
DoGetLineCountFromString();
Finish();
}
void DoGetLineCountFromString()
{
if (theString == null)
{
Debug.LogWarning("String not defined");
return;
}
string[] split = theString.Value.Split('\n');
lineCount.Value = split.Length;
}
}
}
Bye,
Jean