通过定制文件操作的处理,能做好很多强检测或者辅助操作,防止这些问题引起的错误
效果如图所示:

代码很简单:
public class FileMoveUtil : UnityEditor.AssetModificationProcessor
{
const string CHECK_DIR = "Assets/GameRes/";
public static AssetMoveResult OnWillMoveAsset(string oldPath, string newPath)
{
AssetMoveResult result = AssetMoveResult.DidNotMove;
if (oldPath.Contains(FileMoveUtil.CHECK_DIR))
{
bool bValue = EditorUtility.DisplayDialog("提示", "你不应该移动[Assets/GameRes]下的任何资源!", "我就要!", "对不起点错了");
if(!bValue)
{
result = AssetMoveResult.FailedMove;
}
}
return result;
}
}
网友评论