示例#1
0
 public bool IsDescendantOf(PathObject ascendant)
 {
     if (!FullPath.StartsWith(ascendant.FullPath))
     {
         return(false);
     }
     if (FullPath.Length <= ascendant.FullPath.Length || FullPath[ascendant.FullPath.Length] != '/')
     {
         return(false);
     }
     return(true);
 }
示例#2
0
        public bool TrySaveDialog(string title, string name, out PathObject dst)
        {
            var path = EditorUtility.SaveFilePanel(
                title,
                FullPath,
                name,
                "vrm");

            if (string.IsNullOrEmpty(path))
            {
                dst = default;
                return(false);
            }
            dst = PathObject.FromFullPath(path);
            return(true);
        }
示例#3
0
        public void Test()
        {
            var dataPath = PathObject.FromFullPath(Application.dataPath);

            Assert.AreEqual("Assets", dataPath.Stem);

            // UnityRoot
            Assert.True(dataPath.IsDescendantOf(PathObject.UnityRoot));
            // UnityRoot/Assets
            Assert.False(dataPath.IsDescendantOf(PathObject.UnityAssets));
            Assert.AreEqual(dataPath, PathObject.UnityAssets);

            Assert.AreEqual(PathObject.UnityRoot.Child("Assets"), PathObject.UnityAssets);
            Assert.AreEqual(PathObject.UnityAssets.Parent, PathObject.UnityRoot);
            Assert.AreEqual("Assets", PathObject.UnityAssets.UnityAssetPath);
        }
示例#4
0
        public static bool TryGetFromAsset(UnityEngine.Object src, out PathObject dst)
        {
            if (src == null)
            {
                dst = default;
                return(false);
            }

            var assetPath = AssetDatabase.GetAssetPath(src);

            if (string.IsNullOrEmpty(assetPath))
            {
                dst = default;
                return(false);
            }

            dst = FromUnityAssetPath(assetPath);
            return(true);
        }