您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

73 行
1.9 KiB

using System.IO;
using UnityEngine;
namespace UniVRM10
{
public static class StringExtensions
{
public static string ToLowerCamelCase(this string lower)
{
return lower.Substring(0, 1).ToLower() + lower.Substring(1);
}
public static string ToUpperCamelCase(this string lower)
{
return lower.Substring(0, 1).ToUpper() + lower.Substring(1);
}
static string m_unityBasePath;
public static string UnityBasePath
{
get
{
if (m_unityBasePath == null)
{
m_unityBasePath = Path.GetFullPath(Application.dataPath + "/..").Replace("\\", "/");
}
return m_unityBasePath;
}
}
public static string AssetPathToFullPath(this string path)
{
return UnityBasePath + "/" + path;
}
public static bool StartsWithUnityAssetPath(this string path)
{
return path.Replace("\\", "/").StartsWith(UnityBasePath + "/Assets");
}
public static string ToUnityRelativePath(this string path)
{
path = path.Replace("\\", "/");
if (path.StartsWith(UnityBasePath))
{
return path.Substring(UnityBasePath.Length + 1);
}
//Debug.LogWarningFormat("{0} is starts with {1}", path, basePath);
return path;
}
static readonly char[] EscapeChars = new char[]
{
'\\',
'/',
':',
'*',
'?',
'"',
'<',
'>',
'|',
};
public static string EscapeFilePath(this string path)
{
foreach(var x in EscapeChars)
{
path = path.Replace(x, '+');
}
return path;
}
}
}