You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.1 KiB
58 lines
1.1 KiB
10 years ago
|
using UnityEngine;
|
||
|
using System.IO;
|
||
|
using System.Collections;
|
||
|
using System.Text;
|
||
|
using System;
|
||
|
|
||
|
namespace Fungus
|
||
|
{
|
||
|
public class StringFormatter
|
||
|
{
|
||
|
public static string[] FormatEnumNames(Enum e, string firstLabel)
|
||
|
{
|
||
|
string[] enumLabels = Enum.GetNames(e.GetType());
|
||
|
enumLabels[0] = firstLabel;
|
||
|
for (int i=0; i<enumLabels.Length; i++)
|
||
|
{
|
||
|
enumLabels[i] = SplitCamelCase(enumLabels[i]);
|
||
|
}
|
||
|
return enumLabels;
|
||
|
}
|
||
10 years ago
|
|
||
10 years ago
|
public static string SplitCamelCase(string text)
|
||
|
{
|
||
|
if (string.IsNullOrEmpty(text))
|
||
10 years ago
|
{
|
||
10 years ago
|
return "";
|
||
10 years ago
|
}
|
||
|
|
||
10 years ago
|
StringBuilder newText = new StringBuilder(text.Length * 2);
|
||
|
newText.Append(text[0]);
|
||
|
for (int i = 1; i < text.Length; i++)
|
||
|
{
|
||
|
if (char.IsUpper(text[i]) && text[i - 1] != ' ')
|
||
10 years ago
|
{
|
||
10 years ago
|
newText.Append(' ');
|
||
10 years ago
|
}
|
||
10 years ago
|
newText.Append(text[i]);
|
||
|
}
|
||
|
return newText.ToString();
|
||
|
}
|
||
10 years ago
|
|
||
10 years ago
|
public static bool IsNullOrWhiteSpace(string value)
|
||
|
{
|
||
|
if (value != null)
|
||
|
{
|
||
|
for (int i = 0; i < value.Length; i++)
|
||
|
{
|
||
|
if (!char.IsWhiteSpace(value[i]))
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|