playMaker

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

Groo Gadgets

  • Beta Group
  • Full Member
  • *
  • Posts: 175
Make string upper or lower case
« 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

Graham

  • Sr. Member
  • ****
  • Posts: 333
  • I Love Playmaker!
    • Portfolio
Re: Make string upper or lower case
« Reply #1 on: September 12, 2014, 02:47:12 PM »
Thanks Simon, this has come in very handy!
More templates on the Unity Asset Store!

Disclosure: We are using affiliate links to our assets; we may receive a commission for purchases made through them. This helps us to continue developing and maintaining great products!

johannastephen

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

jeanfabre

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

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

 Bye,

 Jean

Groo Gadgets

  • Beta Group
  • Full Member
  • *
  • Posts: 175
Re: Make string upper or lower case
« Reply #4 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

jeanfabre

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

FRickReich

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