24 lines
520 B
Markdown
24 lines
520 B
Markdown
#unity/日常积累
|
|
|
|
绝对路径->相对路径
|
|
|
|
``` cs
|
|
string mp =“H:\unity(project)\New Unity Project\Assets\111.mat”;
|
|
mp = mp.Substring(mp.IndexOf("Assets"));
|
|
mp = mp.Replace('\\', '/');
|
|
```
|
|
|
|
变成Assets\111.mat
|
|
|
|
相对路径->绝对路径
|
|
|
|
``` cs
|
|
string path="Assets\";
|
|
|
|
DirectoryInfo direction = new DirectoryInfo(path);
|
|
FileInfo[] files = direction.GetFiles("*", SearchOption.TopDirectoryOnly);
|
|
|
|
path=files[0].FullName.ToString();
|
|
```
|
|
|
|
变成“H:\unity(project)\New Unity Project\Assets\111.mat“(有空补) |