static void EncryptVideo(MenuCommand cmd) { //获取选择文件夹的路径 string[] str = Selection.assetGUIDs; string path = AssetDatabase.GUIDToAssetPath(str[0]); string newPath = Application.dataPath + "/StreamingAssets/videoNew"; FileTools.CreateDirectory(newPath); //获取指定路径下的指定类型资源 DirectoryInfo root = new DirectoryInfo(path); FileInfo[] files = root.GetFiles("*.mp4"); Rijndael rij = new Rijndael(); RijndaelKey rijKey = rij.CreateKeyAndIV(newPath); for (int i = 0; i < files.Length; i++) { byte[] enBytes = rij.Encrypt(FileTools.ReadFile(files[i].FullName), rijKey.key, rijKey.IV); string strWriteFile = newPath + "/" + files[i].Name; FileTools.CreateFile(strWriteFile, enBytes); EditorUtility.DisplayProgressBar("进度", i + "/" + files.Length + "完成修改值", (float)i / files.Length); } EditorUtility.ClearProgressBar(); AssetDatabase.Refresh(); }