Unity编辑器功能 将选中的文件夹复制一份到其他文件夹

 [MenuItem("Ab包工具/将选中的文件移动到StreamingAssets文件夹下")]
    public  static void MoveFireToStreamA()
    {
        //得到选中文件的数组
        Object[] selectobj = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);
        if (selectobj.Length == 0)
            return;
        for (int i = 0; i < selectobj.Length; i++)
        {
            //得到选中文件夹的路径Path
            string path = AssetDatabase.GetAssetPath(selectobj[i]);
            //LastIndexOf('/') 从后往前找第一个字符为'/'的下标
            //得到选中文件夹的名字
            string name = path.Substring(path.LastIndexOf('/'));
            //AssetDatabase.CopyAsset(A,B) 表示将A路径所在文件复制一份到B路径中
            AssetDatabase.CopyAsset(path, "Assets/StreamingAssets" + name);
        }
    }

猜你喜欢

转载自blog.csdn.net/m0_56283466/article/details/137048680