Playmaker Forum
PlayMaker Updates & Downloads => Share New Actions => Topic started by: Groo Gadgets on September 02, 2013, 04:27:51 PM
-
Hey guys,
Here's an action to make a string all upper or lower case:
// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved.
using UnityEngine;
using HutongGames.PlayMaker;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.String)]
[Tooltip("Coverts a string to upper or lower case.")]
public class ConvertCase : FsmStateAction
{
public enum Case
{
Lower,
Upper
}
[RequiredField]
public FsmString stringVariable;
[Tooltip("Select upper or lower case.")]
public Case operation = Case.Lower;
[RequiredField]
[UIHint(UIHint.Variable)]
public FsmString stringValue;
public bool everyFrame;
public override void Reset()
{
stringVariable = null;
stringValue = null;
everyFrame = false;
}
public override void OnEnter()
{
DoSetStringValue();
if (!everyFrame)
Finish();
}
public override void OnUpdate()
{
DoSetStringValue();
}
void DoSetStringValue()
{
if (stringVariable == null) return;
if (stringValue == null) return;
switch (operation)
{
case Case.Lower:
stringValue.Value = stringVariable.Value.ToLower();
break;
case Case.Upper:
stringValue.Value = stringVariable.Value.ToUpper();;
break;
}
// stringValue.Value = stringVariable.Value.ToLower();
}
}
}
Enjoy!
Simon
-
Thanks Simon, this has come in very handy!
-
Thank you very much ;)
-
Hi,
Cool, I added it to the Ecosystem :) ( renamed ConvertStringCase)
Bye,
Jean
-
Wow thanks Jean. To be honest I can't even remember creating that action! Must have been while I was prototyping a word game a few years back!
Cheers,
Simon
-
Hi,
That's fine :) I just needed that and realize it wasn't covered, so I search the forum and found it. Thanks :)
Bye,
Jean
-
Nice little addition :D