playMaker

Author Topic: Make string upper or lower case  (Read 1743 times)

Groo Gadgets

  • Junior Playmaker
  • **
  • Posts: 95
    • View Profile
Make string upper or lower case
« 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

Graham

  • Sr. Member
  • ****
  • Posts: 282
  • I Love Playmaker!
    • View Profile
    • Portfolio
Re: Make string upper or lower case
« Reply #1 on: September 12, 2014, 11:47:12 AM »
Thanks Simon, this has come in very handy!

johannastephen

  • Playmaker Newbie
  • *
  • Posts: 35
    • View Profile
Re: Make string upper or lower case
« Reply #2 on: April 03, 2015, 09:19:58 AM »
Thank you very much  ;)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12351
  • Official Playmaker Support
    • View Profile
Re: Make string upper or lower case
« Reply #3 on: October 19, 2017, 01:34:08 AM »
Hi,

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

 Bye,

 Jean

Groo Gadgets

  • Junior Playmaker
  • **
  • Posts: 95
    • View Profile
Re: Make string upper or lower case
« Reply #4 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

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12351
  • Official Playmaker Support
    • View Profile
Re: Make string upper or lower case
« Reply #5 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

FRickReich

  • Playmaker Newbie
  • *
  • Posts: 21
    • View Profile
Re: Make string upper or lower case
« Reply #6 on: November 12, 2017, 02:14:46 AM »
Nice little addition :D