using UnityEngine; using System.Collections; using System.Collections.Generic; public class StringUtil { public static string[] Split(string str, char c) { if(Empty(str)) return new string[0]; return str.Split(new char[]{c}); } public static int[] SplitToInt(string str, char c) { if(Empty(str)) return new int[0]; string[] strArr = Split(str, c); int[] intArr = new int[strArr.Length]; for(int i=0; i 0) return true; return false; } public static string Join(List list, string separator) { string str = ""; for (int i = 0; i < list.Count; i++) { str += list[i]; if (i < list.Count - 1) str += separator; } return str; } public static string LimitInput(string text, int limit) { string oldText = text; string newText = WWW.EscapeURL (text); int delta = (newText.Length - oldText.Length)/8; int newLength = oldText.Length + delta; if (newLength > limit) { int reduce = newLength - limit; oldText = oldText.Substring (0, oldText.Length - reduce); } return oldText; } public static List InputValidateCharList = new List{'`', '&', '\\'}; public static char InputValidateHandler(string input, int charIndex, char addedChar) { //Checks if a dollar sign is entered.... if (InputValidateCharList.Contains(addedChar)) { // ... if it is change it to an empty character. addedChar = '\0'; } return addedChar; } }