Skip to content

Instantly share code, notes, and snippets.

@enpel
Created February 18, 2015 01:39
Show Gist options
  • Save enpel/1958842c942483dcc0c5 to your computer and use it in GitHub Desktop.
Save enpel/1958842c942483dcc0c5 to your computer and use it in GitHub Desktop.
NGUIのUIPopupList のイベントで取得する時の文字列に入ってる改行とかをなくすためのStringの拡張
using UnityEngine;
using System.Collections;
public class SampleHogePopupList : MonoBehaviour
{
string keyword = "hogege";
public void PopupListOnChange () {
string key = UIPopupList.current.value.DeleteInvisibleCharacter();
if (keyword == key)
Debug.Log("やったぜ");
}
}
using UnityEngine;
using System.Collections;
public static class StringExtensions
{
public static string DeleteInvisibleCharacter(this string s)
{
return s.Replace("\r", "").Replace("\n", "").Replace("\t", "").Replace(" ", "");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment