Playmaker Forum

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

Title: Make string upper or lower case
Post by: Groo Gadgets on September 02, 2013, 01: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, 11:47:12 AM
Thanks Simon, this has come in very handy!
Title: Re: Make string upper or lower case
Post by: johannastephen on April 03, 2015, 09:19:58 AM
Thank you very much  ;)
Title: Re: Make string upper or lower case
Post by: jeanfabre on October 19, 2017, 01: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, 06: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 19, 2017, 11:38:04 PM
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, 02:14:46 AM
Nice little addition :D