using UnityEngine;
|
using System.Collections;
|
using System.Text;
|
|
public class StringUtility
|
{
|
public static string[] splitSeparator = new string[] { "|" };
|
|
private static StringBuilder s_CacheStringBuilder = new StringBuilder();
|
|
static object lockObject = new object();
|
|
public static string Contact(params object[] _objects)
|
{
|
lock (lockObject)
|
{
|
s_CacheStringBuilder.Remove(0, s_CacheStringBuilder.Length);
|
for (int i = 0; i < _objects.Length; ++i)
|
{
|
if (_objects[i] != null)
|
{
|
s_CacheStringBuilder.Append(_objects[i]);
|
}
|
}
|
return s_CacheStringBuilder.ToString();
|
}
|
}
|
|
|
public static string FormatSpeed(float speed)
|
{
|
if (speed > 1048576f)
|
{
|
return StringUtility.Contact((speed / 1048576f).ToString("f1"), " M/S");
|
}
|
else if (speed > 1024f)
|
{
|
return StringUtility.Contact((speed / 1024f).ToString("f1"), " KB/S");
|
}
|
else
|
{
|
return StringUtility.Contact(speed.ToString("f1"), " B/S");
|
};
|
}
|
|
}
|