mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-13 22:39:39 -05:00
Merge pull request #1941 from ousttrue/fix/UnityPath_edge
[107] Assets 直下に vrm を配置すると例外になるのを修正
This commit is contained in:
@@ -40,7 +40,8 @@ namespace UniGLTF
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If under Assets or under an editable Package return true
|
||||
/// If under Assets or under an editable Package return true.
|
||||
/// For historical reasons "Assets" is true.
|
||||
/// </summary>
|
||||
public bool IsUnderWritableFolder
|
||||
{
|
||||
@@ -152,13 +153,18 @@ namespace UniGLTF
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(Value)) return PathType.Unsuported;
|
||||
if (string.IsNullOrEmpty(Value))
|
||||
{
|
||||
return PathType.Unsupported;
|
||||
}
|
||||
if (Value == "Assets" || Value.FastStartsWith("Assets/"))
|
||||
{
|
||||
// #1941
|
||||
return PathType.Assets;
|
||||
}
|
||||
|
||||
var directory = Path.GetDirectoryName(Value);
|
||||
if (string.IsNullOrEmpty(directory)) return PathType.Unsuported;
|
||||
|
||||
var rootDirectoryName = directory.Split(Path.DirectorySeparatorChar);
|
||||
|
||||
switch (rootDirectoryName[0])
|
||||
{
|
||||
case "Assets":
|
||||
@@ -166,7 +172,7 @@ namespace UniGLTF
|
||||
case "Packages":
|
||||
return PathType.Packages;
|
||||
default:
|
||||
return PathType.Unsuported;
|
||||
return PathType.Unsupported;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -531,6 +537,6 @@ namespace UniGLTF
|
||||
{
|
||||
Assets,
|
||||
Packages,
|
||||
Unsuported,
|
||||
Unsupported,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,6 +159,7 @@ namespace UniGLTF
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Category("UnityPath")]
|
||||
public void UnityPathTest()
|
||||
{
|
||||
// 不正なパス
|
||||
@@ -215,6 +216,32 @@ namespace UniGLTF
|
||||
//var children = root.TraverseDir().ToArray();
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Category("UnityPath")]
|
||||
[TestCase("", PathType.Unsupported)]
|
||||
[TestCase("Assets", PathType.Assets)]
|
||||
[TestCase("Assets/何らかの/パス", PathType.Assets)]
|
||||
[TestCase("Packages", PathType.Unsupported)]
|
||||
[TestCase("Packages/ローカルパッケージ", PathType.Packages)]
|
||||
public void UnityPathPathType(string path, PathType pathType)
|
||||
{
|
||||
var assets = UnityPath.FromUnityPath(path);
|
||||
Assert.AreEqual(pathType, assets.PathType);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Category("UnityPath")]
|
||||
[TestCase("", false)]
|
||||
[TestCase("Assets", true)]
|
||||
[TestCase("Assets/何らかの/パス", true)]
|
||||
[TestCase("Packages", false)]
|
||||
// [TestCase("Packages/存在するローカルパッケージ", true)]
|
||||
public void UnityPathWritableTest(string path, bool expected)
|
||||
{
|
||||
var assets = UnityPath.FromUnityPath(path);
|
||||
Assert.AreEqual(expected, assets.IsUnderWritableFolder);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void VersionChecker()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user