using UnityEngine;
using UnityEditor;
using System.IO;
public class MenuItem_Copy {
[MenuItem("Assets/QuickOp/copy %#v")]
private static void CopyFile()
{
if(Selection.activeObject != null)
{
string path = AssetDatabase.GetAssetOrScenePath(Selection.activeObject);
Debug.Log(path);
string dir = Path.GetDirectoryName(path);
string filename = Path.GetFileNameWithoutExtension(path);
string ext = Path.GetExtension(path);
FileUtil.CopyFileOrDirectory(path, dir + "/" + filename + "_Copy" + ext);
}
}
}
本文介绍了一个在Unity中创建的菜单项,用于快速复制选定的资产文件。通过简单的代码实现,用户可以轻松地将资源复制到指定目录,并添加前缀以避免名称冲突。
977

被折叠的 条评论
为什么被折叠?



