Example #1
0
    public static void ExportBundlesEx()
    {
        ExportScenesManager.AutoSwitchTarget();
        var dirs = Directory.GetDirectories(ExportScenesManager.GetFolderPath(ExportScenesManager.ExportPath));
        //if (files.Length != 0)
        //{
        var currentVersion = new VersionCodeInfo("0.0.0.1");

        foreach (var item in dirs)
        {
            var fileVersion = new VersionCodeInfo(new DirectoryInfo(item).Name);
            if (fileVersion.Compare(currentVersion) > 0)
            {
                currentVersion = fileVersion;
            }
        }
        //var m_currentVersion = currentVersion.GetLowerVersion();
        var m_newVersion       = currentVersion.ToString();
        var m_newVersionFolder = Path.Combine(ExportScenesManager.GetFolderPath(ExportScenesManager.ExportPath), m_newVersion).Replace("\\", "/");

        var targetPath = m_newVersionFolder + BuildProjectExWizard.ExportFilesPath;

        var selection = Selection.GetFiltered(typeof(UnityEngine.Object), SelectionMode.DeepAssets);
        var paths     = (from s in selection
                         let path = AssetDatabase.GetAssetPath(s)
                                    where File.Exists(path)
                                    select path).ToArray();

        foreach (string item in paths)
        {
            Debug.Log("ex " + item);
            ExportBundle(new string[] { item }, targetPath);
        }
    }
Example #2
0
 public override string ToString()
 {
     return(ResouceVersionInfo.ToString());
 }
 //获得被拷贝出去的临时项目路径export下的最新导出版本,比如client_Temp1/Export/0.0.0.3
 public static string GetNewVersionByTempClientPath(string path)
 {
     var dirs = Directory.GetDirectories(path);
     var currentVersion = new VersionCodeInfo("0.0.0.1");
     foreach (var item in dirs)
     {
         var fileVersion = new VersionCodeInfo(new DirectoryInfo(item).Name);
         if (fileVersion.Compare(currentVersion) > 0)
             currentVersion = fileVersion;
     }
     return currentVersion.ToString();
 }
    public void PackManually(string typeName, VersionCodeInfo newVersion)
    {
        var versionFolder = Path.Combine(ExportScenesManager.GetFolderPath(ExportScenesManager.ExportPath), newVersion.ToString());
        var resourceFolder = Path.Combine(versionFolder, typeName);
        var folder = Path.Combine(resourceFolder, ExportScenesManager.SubMogoResources);//获取输出目录

        var folders = new DirectoryInfo(folder).GetDirectories().OrderBy(t => t.CreationTime);
        PackManually(folders.ToList(), typeName, newVersion);
        //ExportScenesManager.PackUpdatedFiles(targetPath, exported, typeName, typeName);//打包更新的文件。
    }
    public void PackManually(List<DirectoryInfo> folders, string typeName, VersionCodeInfo newVersion)
    {
        var versionFolder = Path.Combine(ExportScenesManager.GetFolderPath(ExportScenesManager.ExportPath), newVersion.ToString());
        var resourceFolder = Path.Combine(versionFolder, typeName);

        var targetPath = resourceFolder + "/target";
        var exported = new List<string>();
        foreach (var folderPath in folders)
        {
            LogDebug("folderPath: " + folderPath);
            var files = Directory.GetFiles(folderPath.FullName, "*.*", SearchOption.AllDirectories);
            foreach (var file in files)
            {
                var subPath = file.ReplaceFirst(folderPath.FullName, "");
                var target = targetPath + subPath;
                if (!File.Exists(target))
                {
                    //LogDebug("target: " + target);
                    if (!Directory.Exists(Utils.GetDirectoryName(target.Replace("\\", "/"))))
                        Directory.CreateDirectory(Utils.GetDirectoryName(target.Replace("\\", "/")));
                    File.Copy(file, target);
                    exported.Add(target);
                }
                //else
                //    LogDebug("Same File: " + subPath);
            }
        }
        LogDebug("copy files: " + exported.Count);
    }
 private void BuildResourceInfoManually(VersionCodeInfo currentVersion, VersionCodeInfo newVersion, string typeName, string resFolder, List<string> targets, bool isPopInBuild = false, params string[] extentions)
 {
     //LoadVersion(currentVersion.ToString());
     //var newVersion = currentVersion.GetUpperVersion();
     var versionFolder = Path.Combine(ExportScenesManager.GetFolderPath(ExportScenesManager.ExportPath), newVersion.ToString());
     var targetFolder = Path.Combine(versionFolder, typeName);
     var folder = Path.Combine(targetFolder, ExportScenesManager.SubMogoResources);//获取输出目录
     Stopwatch sw = new Stopwatch();
     sw.Start();
     //Object[] selection = Selection.GetFiltered(typeof(UnityEngine.Object), SelectionMode.DeepAssets);//Selection.objects;
     var expordedFiles = new List<string>();
     foreach (var item in targets)
     {
         var path = "Assets" + item.ReplaceFirst(Application.dataPath, "");
         LogDebug(path);
         var o = AssetDatabase.LoadAssetAtPath(path, typeof(UnityEngine.Object));
         //LogDebug(o);
         var target = folder + "/" + Path.GetFileNameWithoutExtension(item);
         expordedFiles.AddRange(ExportScenesManager.ExportResourcesInfo(new UnityEngine.Object[] { o }, newVersion.ToString(), target, resFolder, isPopInBuild, extentions));//导出资源,并将重新输出的资源返回并记录
         //AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
     }
     LogDebug("m_fileVersions.Count" + m_fileVersions.Count);
     //ExportScenesManager.SaveExportedFileList(expordedFiles, ExportScenesManager.SubExportedFileList, targetFolder, targetFolder);//记录此次导出的文件信息。
     //LogError("SaveExportedFileList time: " + sw.ElapsedMilliseconds);
     //var uFiles = FindUpdatedFiles(folder);//获取有更新的资源。
     //var updatedFiles = uFiles.Keys.ToList();
     //LogError("FindUpdatedFiles time: " + sw.ElapsedMilliseconds);
     //LogError("PackUpdatedFiles time: " + sw.ElapsedMilliseconds);
     //LogError("Total time: " + sw.ElapsedMilliseconds);
     sw.Stop();
     //SaveVersion(newVersion.ToString());
 }
Example #7
0
    public static void ExportBundlesEx()
    {
        ExportScenesManager.AutoSwitchTarget();
        var dirs = Directory.GetDirectories(ExportScenesManager.GetFolderPath(ExportScenesManager.ExportPath));
        //if (files.Length != 0)
        //{
        var currentVersion = new VersionCodeInfo("0.0.0.1");
        foreach (var item in dirs)
        {
            var fileVersion = new VersionCodeInfo(new DirectoryInfo(item).Name);
            if (fileVersion.Compare(currentVersion) > 0)
                currentVersion = fileVersion;
        }
        //var m_currentVersion = currentVersion.GetLowerVersion();
        var m_newVersion = currentVersion.ToString();
        var m_newVersionFolder = Path.Combine(ExportScenesManager.GetFolderPath(ExportScenesManager.ExportPath), m_newVersion).Replace("\\", "/");

        var targetPath = m_newVersionFolder + BuildProjectExWizard.ExportFilesPath;

        var selection = Selection.GetFiltered(typeof(UnityEngine.Object), SelectionMode.DeepAssets);
        var paths = (from s in selection
                     let path = AssetDatabase.GetAssetPath(s)
                     where File.Exists(path)
                     select path).ToArray();
        foreach (string item in paths)
        {
			Debug.Log("ex "+item);
            ExportBundle(new string[] { item }, targetPath);
        }
    }