mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-04-25 15:47:26 -05:00
Replace string.StartsWith and string.EndWith to string.FastStartsWith and string.FastEndWith
This commit is contained in:
parent
433c04acd0
commit
619bb84331
|
|
@ -35,13 +35,13 @@ namespace UniGLTF
|
|||
|
||||
public static bool StartsWithUnityAssetPath(this string path)
|
||||
{
|
||||
return path.Replace("\\", "/").StartsWith(UnityBasePath + "/Assets");
|
||||
return path.Replace("\\", "/").FastStartsWith(UnityBasePath + "/Assets");
|
||||
}
|
||||
|
||||
public static string ToUnityRelativePath(this string path)
|
||||
{
|
||||
path = path.Replace("\\", "/");
|
||||
if (path.StartsWith(UnityBasePath))
|
||||
if (path.FastStartsWith(UnityBasePath))
|
||||
{
|
||||
return path.Substring(UnityBasePath.Length + 1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -368,7 +368,7 @@ namespace UniGLTF
|
|||
}
|
||||
else
|
||||
{
|
||||
if (image.uri.StartsWith("data:"))
|
||||
if (image.uri.FastStartsWith("data:"))
|
||||
{
|
||||
textureName = !string.IsNullOrEmpty(image.name) ? image.name : string.Format("{0:00}#Base64Embedded", imageIndex);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,11 +58,11 @@ namespace UniGLTF
|
|||
return ".jpg";
|
||||
|
||||
default:
|
||||
if (uri.StartsWith("data:image/jpeg;"))
|
||||
if (uri.FastStartsWith("data:image/jpeg;"))
|
||||
{
|
||||
return ".jpg";
|
||||
}
|
||||
else if (uri.StartsWith("data:image/png;"))
|
||||
else if (uri.FastStartsWith("data:image/png;"))
|
||||
{
|
||||
return ".png";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,23 +65,23 @@ namespace UniGLTF
|
|||
|
||||
public static glTFAnimationTarget.AnimationProperties PropertyToTarget(string property)
|
||||
{
|
||||
if (property.StartsWith("m_LocalPosition."))
|
||||
if (property.FastStartsWith("m_LocalPosition."))
|
||||
{
|
||||
return glTFAnimationTarget.AnimationProperties.Translation;
|
||||
}
|
||||
else if (property.StartsWith("localEulerAnglesRaw."))
|
||||
else if (property.FastStartsWith("localEulerAnglesRaw."))
|
||||
{
|
||||
return glTFAnimationTarget.AnimationProperties.EulerRotation;
|
||||
}
|
||||
else if (property.StartsWith("m_LocalRotation."))
|
||||
else if (property.FastStartsWith("m_LocalRotation."))
|
||||
{
|
||||
return glTFAnimationTarget.AnimationProperties.Rotation;
|
||||
}
|
||||
else if (property.StartsWith("m_LocalScale."))
|
||||
else if (property.FastStartsWith("m_LocalScale."))
|
||||
{
|
||||
return glTFAnimationTarget.AnimationProperties.Scale;
|
||||
}
|
||||
else if (property.StartsWith("blendShape."))
|
||||
else if (property.FastStartsWith("blendShape."))
|
||||
{
|
||||
return glTFAnimationTarget.AnimationProperties.BlendShape;
|
||||
}
|
||||
|
|
@ -97,7 +97,7 @@ namespace UniGLTF
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
if (property.EndsWith(".y") || property.StartsWith("blendShape."))
|
||||
if (property.EndsWith(".y") || property.FastStartsWith("blendShape."))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ namespace UniGLTF
|
|||
public ArraySegment<byte> Get(string url)
|
||||
{
|
||||
var bytes =
|
||||
(url.StartsWith("data:"))
|
||||
(url.FastStartsWith("data:"))
|
||||
? UriByteBuffer.ReadEmbedded(url)
|
||||
: File.ReadAllBytes(Path.Combine(m_root, url))
|
||||
;
|
||||
|
|
@ -48,7 +48,7 @@ namespace UniGLTF
|
|||
|
||||
public string GetPath(string url)
|
||||
{
|
||||
if (url.StartsWith("data:"))
|
||||
if (url.FastStartsWith("data:"))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ namespace UniGLTF
|
|||
{
|
||||
if (string.IsNullOrEmpty(generatorVersion)) return false;
|
||||
if (generatorVersion == "UniGLTF") return true;
|
||||
if (!generatorVersion.StartsWith("UniGLTF-")) return false;
|
||||
if (!generatorVersion.FastStartsWith("UniGLTF-")) return false;
|
||||
|
||||
try
|
||||
{
|
||||
|
|
@ -475,7 +475,7 @@ namespace UniGLTF
|
|||
var image = GLTF.GetImageFromTextureIndex(i);
|
||||
if (imageBaseDir.IsUnderAssetsFolder
|
||||
&& !string.IsNullOrEmpty(image.uri)
|
||||
&& !image.uri.StartsWith("data:")
|
||||
&& !image.uri.FastStartsWith("data:")
|
||||
)
|
||||
{
|
||||
///
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ namespace UniGLTF
|
|||
{
|
||||
return false;
|
||||
}
|
||||
return Value == "Assets" || Value.StartsWith("Assets/");
|
||||
return Value == "Assets" || Value.FastStartsWith("Assets/");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ namespace UniGLTF
|
|||
return false;
|
||||
}
|
||||
|
||||
return FullPath.StartsWith(Application.streamingAssetsPath + "/");
|
||||
return FullPath.FastStartsWith(Application.streamingAssetsPath + "/");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -276,7 +276,7 @@ namespace UniGLTF
|
|||
Value = ""
|
||||
};
|
||||
}
|
||||
else if (fullPath.StartsWith(BaseFullPath + "/"))
|
||||
else if (fullPath.FastStartsWith(BaseFullPath + "/"))
|
||||
{
|
||||
return new UnityPath(fullPath.Substring(BaseFullPath.Length + 1));
|
||||
}
|
||||
|
|
@ -288,7 +288,7 @@ namespace UniGLTF
|
|||
|
||||
public static bool IsUnderAssetFolder(string fullPath)
|
||||
{
|
||||
return fullPath.Replace("\\", "/").StartsWith(AssetFullPath);
|
||||
return fullPath.Replace("\\", "/").FastStartsWith(AssetFullPath);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ namespace VRM
|
|||
var asset = ScriptableObject.CreateInstance<BlendShapeClip>();
|
||||
var groupName = group.name;
|
||||
var prefix = "BlendShape.";
|
||||
while (groupName.StartsWith(prefix))
|
||||
while (groupName.FastStartsWith(prefix))
|
||||
{
|
||||
groupName = groupName.Substring(prefix.Length);
|
||||
}
|
||||
|
|
@ -195,8 +195,8 @@ namespace VRM
|
|||
|
||||
var material = GetMaterials().FirstOrDefault(y => y.name == x.materialName);
|
||||
var propertyName = x.propertyName;
|
||||
if (x.propertyName.EndsWith("_ST_S")
|
||||
|| x.propertyName.EndsWith("_ST_T"))
|
||||
if (x.propertyName.FastEndsWith("_ST_S")
|
||||
|| x.propertyName.FastEndsWith("_ST_T"))
|
||||
{
|
||||
propertyName = x.propertyName.Substring(0, x.propertyName.Length - 2);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user