123456789101112131415161718192021222324252627282930313233343536373839 |
- namespace labelUtility
- {
- using System.IO;
- using UnityEngine;
- public static class ExPath
- {
- public static string GetRelativePath(this string path)
- {
- return "Assets" + path.Replace(Application.dataPath, "");
- }
- public static string GetUnRepeatFileName(this string fileName)
- {
- string extension = Path.GetExtension(fileName);
- string directory = Path.GetDirectoryName(fileName);
- string name = Path.GetFileNameWithoutExtension(fileName);
- int count = 0;
- string newFileName = $"{directory}/{name}{extension}";
- while (File.Exists(newFileName))
- {
- count++;
- newFileName = $"{directory}/{name} ({count}){extension}";
- }
- return newFileName;
- }
- }
- }
|