Skip to content

Commit e117a0a

Browse files
committed
feat: Add to data path
1 parent 58f29c2 commit e117a0a

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

Assets/JCSUnity/Scripts/Util/JCS_Path.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,22 @@ public static string Combine(params string[] list)
5858
///
5959
/// The returned string should start with `Assets/`.
6060
/// </summary>
61-
public static string ToAsset(string path)
61+
public static string ToAssetPath(string path)
6262
{
6363
return path.Replace(Application.dataPath, "Assets");
6464
}
65+
66+
/// <summary>
67+
/// Convert an asset path to data path.
68+
///
69+
/// This returns an absolute full path.
70+
/// </summary>
71+
public static string ToDataPath(string path)
72+
{
73+
if (path.StartsWith(Application.dataPath))
74+
return path;
75+
76+
return Combine(Application.dataPath, path);
77+
}
6578
}
6679
}

docs/ScriptReference/Util/JCS_Path.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
The utility module for handling path issues.
44

5-
| Name | Description |
6-
|:----------|:----------------------------------------------------------|
7-
| Normalize | Return the normalized path. |
8-
| Combine | Safe way to combine multiple path to one path with slash. |
9-
| ToAsset | Convert a path to asset compatible path. |
5+
| Name | Description |
6+
|:------------|:----------------------------------------------------------|
7+
| Normalize | Return the normalized path. |
8+
| Combine | Safe way to combine multiple path to one path with slash. |
9+
| ToAssetPath | Convert a path to asset compatible path. |
10+
| ToDataPath | Convert an asset path to data path. |

0 commit comments

Comments
 (0)