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); }
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); }
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); }
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); }