Exemplo n.º 1
0
        public FileInfo Backup(string file)
        {
            FileStream fs = null;

            try
            {
                fs = File.Create(file);
            }
            catch (DirectoryNotFoundException)
            {
                UtilityFile.CreateDirectory(Path.GetDirectoryName(file));
                this.Backup(file);
            }
            catch (IOException)
            {
                FileAttributes fileAtts = FileAttributes.Normal;
                //先获取此文件的属性
                fileAtts = System.IO.File.GetAttributes(file);
                //讲文件属性设置为普通(即没有只读和隐藏等)
                System.IO.File.SetAttributes(file, FileAttributes.Normal);
                System.IO.File.Delete(file);
                this.Backup(file);
            }
            this.OptionDocument.Save(fs);
            return(new FileInfo(file));
        }
Exemplo n.º 2
0
    /// <summary>
    /// 压缩文件
    /// </summary>
    public void PackerAssets()
    {
        // 打包资源文件成 UPK 压缩文件
        string tempPath = BuildConst.PackerPath;

        UtilityFile.CreateDirectory(tempPath);
        UtilityPacker.PackFolder(tempPath, BuildConst.PackerFilePath);

        AssetDatabase.Refresh();
    }
Exemplo n.º 3
0
    public void GeneratePbFiles(string _protoPath)
    {
        List <FileInfo> tempProtoFileList = UtilityFile.GetDirectoryAllFile(_protoPath, "proto");

        UtilityFile.DeleteFileOrDirectory(BuildConst.BuildPbPath);
        UtilityFile.CreateDirectory(BuildConst.BuildPbPath);
        for (int i = 0; i < tempProtoFileList.Count; ++i)
        {
            FileInfo tempFile = tempProtoFileList[i];
            GeneratePbFile(tempFile.FullName, _protoPath);
        }
    }
Exemplo n.º 4
0
    void BuildAssetBundle(BuildTarget _target, string _versionType = "")
    {
        if (_target == BuildTarget.iOS)
        {
            File.WriteAllText(PlatformNumberFilePath, "2000");
            File.WriteAllText(VersionNumberFilePath, EditorTool.Utility.GetVersionNumber(BuildConst.IosServer).ToString());
        }
        else if (_target == BuildTarget.Android)
        {
            File.WriteAllText(PlatformNumberFilePath, "3000");
            File.WriteAllText(VersionNumberFilePath, EditorTool.Utility.GetVersionNumber(BuildConst.AndroidServer).ToString());
        }

        UtilityFile.CreateDirectory(BuildConst.BuildAssetPath);
        BuildPipeline.BuildAssetBundles(BuildConst.BuildAssetPath, BuildAssetBundleOptions.ChunkBasedCompression, _target);
    }
Exemplo n.º 5
0
    void DoSetFolderAssetBundleName(string _name, string _folderName, string[] _searchPatternArray)
    {
        string tempPath = BuildConst.AssetPath + _folderName;

        UtilityFile.CreateDirectory(tempPath);

        List <FileParamInfo> tempInfoList = UtilityFile.GetDirectoryAllAssetsFile(tempPath, _searchPatternArray);

        if (tempInfoList == null)
        {
            return;
        }

        for (int i = 0; i < tempInfoList.Count; i++)
        {
            DoSetAssetBundleName(_name + tempInfoList[i].FileName, tempInfoList[i].FilePath);
        }
    }
Exemplo n.º 6
0
    void BuildAssetBundleFolder(string _folderPath, BuildTarget _target)
    {
        List <BuildBundleInfo> tempList = buildBundleFolderLib.GetBundleInfoList();

        AssetBundleBuild[] tempAssetBundleArray = new AssetBundleBuild[tempList.Count];
        for (int i = 0; i < tempAssetBundleArray.Length; i++)
        {
            BuildBundleInfo tempInfo = tempList[i];
            tempAssetBundleArray[i].assetBundleName = tempInfo.Prefix + tempInfo.Path + BuildConst.ExtName;
            List <FileParamInfo> tempInfoList   = UtilityFile.GetDirectoryAllAssetsFile(_folderPath + tempInfo.Path, tempInfo.SuffixArray);
            string[]             tempAssetNames = new string[tempInfoList.Count];
            for (int j = 0; j < tempAssetNames.Length; j++)
            {
                tempAssetNames[j] = tempInfoList[j].FilePath;
            }

            tempAssetBundleArray[i].assetNames = tempAssetNames;
        }

        UtilityFile.CreateDirectory(BuildConst.BuildFolderAssetPath);
        BuildPipeline.BuildAssetBundles(BuildConst.BuildFolderAssetPath, tempAssetBundleArray, BuildAssetBundleOptions.ChunkBasedCompression, _target);
    }