ProjectDDD/Assets/_Datas/02.Scripts/Utils.cs
2025-06-17 20:47:57 +09:00

45 lines
1.1 KiB (Stored with Git LFS)
C#

using System.IO;
using UnityEditor;
namespace DDD
{
public static class Utils
{
public static string FixPath(string path)
{
path = path.Replace('\\', '/');
path = path.Replace("//", "/");
while (path.Length > 0 && path[0] == '/')
{
path = path.Remove(0, 1);
}
return path;
}
public static string FileName(string path)
{
return Path.GetFileNameWithoutExtension(path);
}
public static string FolderPath(string path)
{
return FixPath(Path.GetDirectoryName(path));
}
public static void MakeFolderFromFilePath(string filePath)
{
var paths = FixPath(filePath).Split('/');
var path = "";
for (var i = 0; i < paths.Length - 1; ++i)
{
path += paths[i] + "/";
if (Directory.Exists(path) == false)
{
Directory.CreateDirectory(path);
AssetDatabase.Refresh();
}
}
}
}
}