Author Topic: StringAddNewLine  (Read 1777 times)


  • Administrator
  • Hero Member
  • *****
  • Posts: 15212
  • Official Playmaker Support
    • View Profile
« on: February 21, 2012, 11:39:54 PM »
Lackedof inspiration for the name.. so if someone finds a better name, I'll change it :)

 basically, I need to add new lines to a string, and while its possible with buildString ( by copying pasting a newline cahr from a text editor and put it in the separator, etc etc), it's not very nice, so I wrote a specific action for this.

 This is very good for chat applications for example or logging stuff easily on screen.

Code: [Select]
// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved.

using UnityEngine;

namespace HutongGames.PlayMaker.Actions
[Tooltip("Adds strings together seprated by a line.")]
public class StringAddNewLine : FsmStateAction
[Tooltip("List of the strings to compose.")]
public FsmString[] stringParts;

[Tooltip("Store the result.")]
public FsmString storeResult;

public override void Reset()
stringParts = new FsmString[2];

storeResult = null;

public override void OnEnter()


void DoBuildString()
if (storeResult == null) return;

string result = "";
int count = stringParts.Length;
for(int i=0;i<count;i++)
if (result != "")
result += "\n";

result += stringParts[i];

    storeResult.Value = result;