Playmaker Forum

PlayMaker Updates & Downloads => Share New Actions => Topic started by: Groo Gadgets on September 02, 2013, 04:27:51 PM

Title: Make string upper or lower case
Post 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:

Code: [Select]
// (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
Title: Re: Make string upper or lower case
Post by: Graham on September 12, 2014, 02:47:12 PM
Thanks Simon, this has come in very handy!
Title: Re: Make string upper or lower case
Post by: johannastephen on April 03, 2015, 12:19:58 PM
Thank you very much  ;)
Title: Re: Make string upper or lower case
Post by: jeanfabre on October 19, 2017, 04:34:08 AM
Hi,

 Cool, I added it to the Ecosystem :) ( renamed ConvertStringCase)

 Bye,

 Jean
Title: Re: Make string upper or lower case
Post by: Groo Gadgets on October 19, 2017, 09:42:34 AM
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
Title: Re: Make string upper or lower case
Post by: jeanfabre on October 20, 2017, 02:38:04 AM
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
Title: Re: Make string upper or lower case
Post by: FRickReich on November 12, 2017, 04:14:46 AM
Nice little addition :D