38 lines
1017 B
C#
38 lines
1017 B
C#
using System.IO;
|
|
using UnityEngine;
|
|
|
|
public static class LTEditorUtils
|
|
{
|
|
|
|
public static string GetRealPath(string assetPath)
|
|
{
|
|
// Assets/Art/Animations/animator/AutoGen_Characters
|
|
return assetPath.Replace("Assets/", Application.dataPath + "/");
|
|
}
|
|
|
|
public static string GetDirPath(string filePath)
|
|
{
|
|
// 找到最后一个/
|
|
var lastIndex = filePath.LastIndexOf('/');
|
|
if (lastIndex == -1)
|
|
{
|
|
return filePath;
|
|
}
|
|
return filePath.Substring(0, lastIndex);
|
|
}
|
|
|
|
public static void MakeDirExist(string assetPath)
|
|
{
|
|
if (assetPath.StartsWith("Assets/"))
|
|
{
|
|
assetPath = GetRealPath(assetPath);
|
|
}
|
|
var dirPath = GetDirPath(assetPath);
|
|
if (!Directory.Exists(dirPath))
|
|
{
|
|
Directory.CreateDirectory(dirPath);
|
|
}
|
|
}
|
|
|
|
}
|