public void RemoveProfileRecord(ref VersionBranch branch, long versionCode)
        {
            bool isMainPackage = (branch.BType == VersionBranch.BranchType.MainPackage);

            //删除data
            string data_folder = VFSEditorUtil.GetVersionDataFolderPath_InProjectVersion(branch.BranchName, versionCode); //存放数据的地方

            XDirectory.DeleteIfExists(data_folder, true);

            //删除二进制
            string binary_folder = VFSEditorUtil.Get_AssetsBinaryFolderPath_InVersion(branch.BranchName, versionCode);

            XDirectory.DeleteIfExists(binary_folder);

            //在索引中删除记录
            foreach (var item in branch.VersionRecords_ReadWrite)
            {
                if (item.versionCode == versionCode)
                {
                    branch.VersionRecords_ReadWrite.Remove(item);
                    break;
                }
            }
            //保存索引
            SaveBranchFile(ref branch);
        }
Example #2
0
        /// <summary>
        /// 保存EditorBuildInfo
        /// </summary>
        /// <param name="package_root_path"></param>
        private void MakeEditorBuildInfo(string package_root_path)
        {
            mEditorBuildInfo.build_profile_name = curProfile.ProfileName;
            mEditorBuildInfo.ReadySave();
            string path = VFSEditorUtil.Get_EditorBuildInfoPath(package_root_path);

            XFile.DeleteIfExists(path);
            XDirectory.CreateIfNotExists(Path.GetDirectoryName(path));
            XConfig.SaveJson(mEditorBuildInfo, path, AssetLoadType.SystemIO);
        }
Example #3
0
        public void Build(XRuntimePlatform platform, AssetCompressType compressType)
        {
            Debug.Log("[TinaX.VFS] Start build assets...");
            if (ClearAssetBundleSignBeforeBuild)
            {
                VFSEditorUtil.RemoveAllAssetbundleSigns();
            }
            Debug.Log("    handle assetbundle signs...");
            RefreshAssetBundleSign();
            Debug.Log("    build assetbundles by unity editor.");

            string packages_root_path;  //VFS存放相关文件的根目录
            string output_temp_path;    //Unity自身打包后直接输出的目录

            BuildAssetBundle(platform, compressType, out packages_root_path, out output_temp_path);

            #region 加载Build得到的AssetbundleManifest文件
            string      abmanifest_file_name = Path.GetFileName(output_temp_path);
            string      abmanifest_path      = Path.Combine(output_temp_path, abmanifest_file_name);
            AssetBundle ab_mainifest         = AssetBundle.LoadFromFile(abmanifest_path);
            mAssetBundleManifest = ab_mainifest.LoadAsset <AssetBundleManifest>("AssetBundleManifest");
            #endregion

            HandleVFSFiles(packages_root_path, output_temp_path, platform);
            SaveAssetHashFiles(Path.Combine(packages_root_path, VFSEditorConst.PROJECT_VFS_FILE_FOLDER_DATA));
            MakeEditorBuildInfo(packages_root_path);
            MakeBuildInfo(packages_root_path);
            MakeVFSConfig(packages_root_path, Config);

            if (CopyToStreamingAssetsFolder)
            {
                CopyToStreamingAssets(packages_root_path, XPlatformUtil.GetNameText(platform));
            }

            if (ClearAssetBundleSignAfterBuild)
            {
                VFSEditorUtil.RemoveAllAssetbundleSigns();
            }

            Debug.Log("[TinaX.VFS] Build Finished.");
        }
        public void RemoveBranch(string branchName)
        {
            string blower = branchName.ToLower();

            for (int i = mVersionMainData.Branches_ReadWrite.Count - 1; i >= 0; i--)
            {
                if (mVersionMainData.Branches_ReadWrite[i].ToLower() == blower)
                {
                    string branch = mVersionMainData.Branches_ReadWrite[i];

                    //删除branch的目录信息

                    //index
                    string branch_index_path = Path.Combine(mVersionData_BranchIndex_FolderPath, branch + ".json");
                    XFile.DeleteIfExists(branch_index_path);
                    //版本数据
                    string branch_version_data_folder_path = VFSEditorUtil.GetVersionDataRootFolderPath_InProjectVersion(ref branchName);
                    XDirectory.DeleteIfExists(branch_version_data_folder_path, true);

                    //二进制文件
                    string branch_binary_data_folder_path = Path.Combine(mVersionBinary_Branches_FolderPath, branch);
                    XDirectory.DeleteIfExists(branch_binary_data_folder_path, true);

                    //删除索引记录
                    mVersionMainData.Branches_ReadWrite.RemoveAt(i);
                    //删除字典
                    if (mDict_Branches.ContainsKey(branch))
                    {
                        mDict_Branches.Remove(branch);
                    }
                }
            }

            //保存更新后的分子索引
            SaveVersionMainData(ref mVersionMainData, mVersionMainFilePath);
        }
Example #5
0
        private static DateTime mCurAssetDataTime; //获取Asset查询结果时,VFSManager的刷新时间

        private static void OnPostHeaderGUI(Editor editor)
        {
            if (VFSManagerEditor.VFSConfig == null)
            {
                return;
            }
            if (editor.targets.Length == 1)
            {
                string guid = string.Empty;
                if (VFSEditorUtil.GetPathAndGUIDFromTarget(editor.target, out string path, ref guid, out Type mainAssetType))
                {
                    mCurSelectedAssetPath = path;


                    if (!IsTypeIgnore(mainAssetType) && path.StartsWith("Assets/") && !editor.target.name.IsNullOrEmpty())
                    {
                        if (mCurSelectedAssetPath != mCurShowAssetPath || mCurAssetDataTime != VFSManagerEditor.LastRefreshManagerTime)
                        {
                            //获取数据
                            VFSManagerEditor.QueryAsset(path, out mCurAssetData, false);
                            mCurShowAssetPath = mCurSelectedAssetPath;
                            mCurAssetDataTime = VFSManagerEditor.LastRefreshManagerTime;
                        }

                        GUILayout.Space(10);

                        EditorGUILayout.BeginVertical(style_bg);
                        EditorGUILayout.LabelField("VFS Preview", EditorStyles.centeredGreyMiniLabel);

                        if (mCurAssetData.ManagedByVFS)
                        {
                            GUILayout.Label("Managed By VFS.", style_txt_bold);

                            GUILayout.BeginHorizontal();
                            GUILayout.Label("Group : ", style_txt_bold, GUILayout.MaxWidth(95));
                            EditorGUILayout.LabelField(mCurAssetData.GroupName);
                            GUILayout.EndHorizontal();

                            GUILayout.BeginHorizontal();
                            GUILayout.Label("Build Type :", style_txt_bold, GUILayout.MaxWidth(95));
                            EditorGUILayout.LabelField(mCurAssetData.BuildType.ToString());
                            GUILayout.EndHorizontal();

                            GUILayout.BeginHorizontal();
                            GUILayout.Label("Develop Type :", style_txt_bold, GUILayout.MaxWidth(95));
                            EditorGUILayout.LabelField(mCurAssetData.DevType.ToString());
                            GUILayout.EndHorizontal();

                            GUILayout.BeginHorizontal();
                            GUILayout.Label("AB Path : ", style_txt_bold, GUILayout.MaxWidth(65));
                            EditorGUILayout.LabelField(mCurAssetData.AssetBundleFileName);
                            GUILayout.EndHorizontal();

                            GUILayout.BeginHorizontal();
                            if (GUILayout.Button(IsChinese?"复制路径":"Copy Path", GUILayout.Width(80)))
                            {
                                GUIUtility.systemCopyBuffer = path;
                            }
                            GUILayout.EndHorizontal();
                        }
                        else
                        {
                            GUILayout.Label("Non VFS managed asset.");
                            GUILayout.BeginHorizontal(style_btn);
                            if (GUILayout.Button("Dashboard"))
                            {
                                VFSConfigDashboardIMGUI.OpenUI();
                            }
                            GUILayout.EndHorizontal();
                        }

                        EditorGUILayout.Separator();

                        EditorGUILayout.EndVertical();
                    }
                }
            }
        }
        /// <summary>
        /// 添加版本记录
        /// </summary>
        /// <param name=""></param>
        public void AddVersionRecord(string branchName, long versionCode, string versionName, string versionDesc, bool saveBinary, bool dialog = true, bool log = true)
        {
            //编辑器那边限制了不能添加“比最大版本号更小的版本号”的版本,(也就是说版本号只能变大),但是这里实际上没做这个限制。以后如果有需要,可以让编辑器UI上去掉限制。
            if (mDict_Branches.TryGetValue(branchName, out var branch))
            {
                //判断一下版本号啦
                if (versionCode >= 0 && !branch.IsVersionCodeExists(versionCode))
                {
                    bool isMainPackage      = (branch.BType == VersionBranch.BranchType.MainPackage);
                    bool flag_process_error = false; //处理文件过程中如果出错则中断操作且不记录数据

                    string platform_name = XPlatformUtil.GetNameText(branch.Platform);
                    string source_packages_folder_path = VFSEditorUtil.GetSourcePackagesFolderPath(platform_name);
                    string data_folder = VFSEditorUtil.GetVersionDataFolderPath_InProjectVersion(branch.BranchName, versionCode); //存放数据的地方

                    string build_id = string.Empty;

                    try
                    {
                        XDirectory.DeleteIfExists(data_folder, true);
                        Directory.CreateDirectory(data_folder);

                        //复制并存档assets_hash文件
                        string assets_hash_path        = isMainPackage ? VFSEditorUtil.GetMainPackage_AssetsHashFilePath_InSourcePackagesFolder(platform_name) : VFSEditorUtil.GetExtensionGroup_AssetsHashFilePath_InSourcePackagesFolder(platform_name, branch.ExtensionGroupName);
                        string assets_hash_target_path = Path.Combine(data_folder, VFSConst.AssetsHashFileName);
                        if (File.Exists(assets_hash_path))
                        {
                            File.Copy(assets_hash_path, assets_hash_target_path, true);
                        }

                        //复制并存档Manifest文件
                        string manifest_target_path = VFSEditorUtil.GetVersionData_Manifest_FolderOrFilePath(!isMainPackage, branchName, versionCode);
                        string manifest_path        = isMainPackage ? VFSEditorUtil.GetMainPackage_AssetBundleManifestsFolderPath_InSourcePackagesFolder(platform_name) : VFSEditorUtil.GetExtensionGroup_AssetBundleManifestPath_InInSourcePackagesFolder(platform_name, branch.ExtensionGroupName);
                        if (isMainPackage)
                        {
                            if (Directory.Exists(manifest_path))
                            {
                                XDirectory.CopyDir(manifest_path, manifest_target_path);
                            }
                        }
                        else
                        {
                            if (File.Exists(manifest_path))
                            {
                                File.Copy(manifest_path, manifest_target_path);
                            }
                        }

                        //复制并存档AssetBundleHashs
                        string ab_hash_path        = isMainPackage ? VFSEditorUtil.GetMainPackage_AssetBundle_HashFiles_FolderPath_InSourcePackagesFolder(platform_name) : VFSEditorUtil.GetExtensionGroup_AssetBundle_HashFiles_Path_InInSourcePackagesFolder(platform_name, branch.ExtensionGroupName);
                        string ab_hash_target_path = VFSEditorUtil.GetVersionData_AssetBundle_HashFile_FolderOrFilePath(!isMainPackage, branchName, versionCode);
                        if (isMainPackage)
                        {
                            if (Directory.Exists(ab_hash_path))
                            {
                                XDirectory.CopyDir(ab_hash_path, ab_hash_target_path);
                            }
                        }
                        else
                        {
                            if (File.Exists(ab_hash_path))
                            {
                                File.Copy(ab_hash_path, ab_hash_target_path);
                            }
                        }

                        //复制并存档vfs config (main package)
                        if (isMainPackage)
                        {
                            string vfs_config_path = VFSUtil.GetVFSConfigFilePath_InPackages(VFSEditorUtil.GetSourcePackagesFolderPath(platform_name));
                            if (File.Exists(vfs_config_path))
                            {
                                string target_path = Path.Combine(data_folder, VFSConst.Config_Runtime_FileName);
                                File.Copy(vfs_config_path, target_path, true);
                            }
                        }

                        //Group Options
                        if (!isMainPackage)
                        {
                            string group_option_path = VFSUtil.GetExtensionPackages_GroupOptions_FilePath(source_packages_folder_path, branch.ExtensionGroupName);
                            if (File.Exists(group_option_path))
                            {
                                string target_path = Path.Combine(data_folder, VFSConst.ExtensionGroup_GroupOption_FileName);
                                File.Copy(group_option_path, target_path, true);
                            }
                        }

                        //Group Info
                        if (!isMainPackage)
                        {
                            string group_info_path = VFSUtil.GetExtensionGroup_GroupInfo_Path_InGroupPath(VFSUtil.GetExtensionGroupFolder(source_packages_folder_path, branch.ExtensionGroupName));
                            if (File.Exists(group_info_path))
                            {
                                string target_path = Path.Combine(data_folder, VFSConst.VFS_ExtensionGroupInfo_FileName);
                                File.Copy(group_info_path, target_path, true);
                            }
                        }

                        //复制并存档editor build info
                        string editor_build_info_path = VFSEditorUtil.Get_EditorBuildInfoPath(VFSEditorUtil.GetSourcePackagesFolderPath(platform_name));
                        if (File.Exists(editor_build_info_path))
                        {
                            string target_path = VFSEditorUtil.GetVersionData_EditorBuildInfo_Path(branchName, versionCode);
                            File.Copy(editor_build_info_path, target_path);
                        }

                        //复制并存档 build info
                        string build_info_path = VFSUtil.GetMainPackage_BuildInfo_Path(VFSEditorUtil.GetSourcePackagesFolderPath(platform_name));
                        if (File.Exists(build_info_path))
                        {
                            //存档
                            string target_path = VFSEditorUtil.GetVersionData_BuildInfo_Path(branchName, versionCode);
                            File.Copy(build_info_path, target_path);

                            //反写版本信息到source package
                            string build_info_json = File.ReadAllText(target_path, Encoding.UTF8);
                            var    obj             = JsonUtility.FromJson <BuildInfo>(build_info_json);

                            build_id = obj.BuildID;

                            //写出版本信息
                            var version_info = new PackageVersionInfo
                            {
                                version     = versionCode,
                                versionName = versionName,
                                buildId     = obj.BuildID,
                                branch      = branch.BranchName
                            };
                            string version_info_path = isMainPackage ? VFSEditorUtil.Get_MainPackage_PackageVersionFilePath_InSourcePackages(platform_name) : VFSEditorUtil.Get_ExtensionGroups_PackageVersionFilePath_InSourcePackages(ref platform_name, ref branch.ExtensionGroupName);
                            XFile.DeleteIfExists(version_info_path);
                            XConfig.SaveJson(version_info, version_info_path, AssetLoadType.SystemIO);

                            //检查当前StreamingAssets中是否有与之build id一致的情况,如果有,也写出
                            if (isMainPackage)
                            {
                                string buildinfo_in_stream = VFSUtil.GetMainPackage_BuildInfo_Path(VFSUtil.GetPackagesRootFolderInStreamingAssets(platform_name));
                                if (File.Exists(buildinfo_in_stream))
                                {
                                    try
                                    {
                                        var obj_stream = XConfig.GetJson <BuildInfo>(buildinfo_in_stream, AssetLoadType.SystemIO, false);
                                        if (obj_stream.BuildID == obj.BuildID)
                                        {
                                            //一致,写出
                                            string target_stream = VFSUtil.GetMainPackage_VersionInfo_Path(VFSUtil.GetPackagesRootFolderInStreamingAssets(platform_name));
                                            XConfig.SaveJson(version_info, target_stream, AssetLoadType.SystemIO);
                                        }
                                    }
                                    catch { }
                                }
                            }
                            else
                            {
                                string buildinfo_in_stream = VFSUtil.GetExtensionGroup_BuildInfo_Path(VFSUtil.GetPackagesRootFolderInStreamingAssets(platform_name), branch.ExtensionGroupName);
                                if (File.Exists(buildinfo_in_stream))
                                {
                                    try
                                    {
                                        var obj_stream = XConfig.GetJson <BuildInfo>(buildinfo_in_stream, AssetLoadType.SystemIO, false);
                                        if (obj_stream.BuildID == obj.BuildID)
                                        {
                                            //一致,写出
                                            string target_stream = VFSUtil.GetExtensionGroup_VersionInfo_Path(VFSUtil.GetPackagesRootFolderInStreamingAssets(platform_name), branch.ExtensionGroupName);
                                            XConfig.SaveJson(version_info, target_stream, AssetLoadType.SystemIO);
                                        }
                                    }
                                    catch { }
                                }
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        XDirectory.DeleteIfExists(data_folder, true);
                        flag_process_error = true;
                        throw e;
                    }

                    //保存二进制文件
                    if (saveBinary && !flag_process_error)
                    {
                        string binary_path = VFSEditorUtil.Get_AssetsBinaryFolderPath_InVersion(branchName, versionCode);

                        try
                        {
                            long total_count = 0;
                            //把所有二进制文件直接全拷进去
                            string binary_path_temp        = Path.Combine(binary_path, "temp");
                            string binary_path_temp_remote = Path.Combine(binary_path, "temp_remote");
                            XDirectory.DeleteIfExists(binary_path_temp, true);
                            Directory.CreateDirectory(binary_path_temp);

                            if (isMainPackage)
                            {
                                XDirectory.DeleteIfExists(binary_path_temp_remote, true);
                                Directory.CreateDirectory(binary_path_temp_remote);
                            }


                            //移动文件
                            if (isMainPackage)
                            {
                                string   local_path     = VFSEditorUtil.Get_MainPackage_AssetsFolderPath_InSourcePackages(platform_name);
                                int      local_path_len = local_path.Length + 1;
                                string[] local_files    = Directory.GetFiles(local_path, "*.*", SearchOption.AllDirectories);
                                if (local_files != null && local_files.Length > 0)
                                {
                                    ArrayUtil.RemoveDuplicationElements(ref local_files);
                                    foreach (var item in local_files)
                                    {
                                        total_count++;
                                        string pure_path   = item.Substring(local_path_len, item.Length - local_path_len);
                                        string target_path = Path.Combine(binary_path_temp, pure_path);
                                        XDirectory.CreateIfNotExists(Path.GetDirectoryName(target_path));
                                        File.Copy(item, target_path);
                                    }
                                }

                                string remote_path = VFSEditorUtil.Get_MainPackage_RemoteAssetsFolderPath_InSourcePackages(platform_name);
                                if (Directory.Exists(remote_path))
                                {
                                    int      remote_path_len = remote_path.Length + 1;
                                    string[] remote_files    = Directory.GetFiles(remote_path, "*.*", SearchOption.AllDirectories);
                                    if (remote_files != null && remote_files.Length > 0)
                                    {
                                        total_count++;
                                        ArrayUtil.RemoveDuplicationElements(ref remote_files);
                                        foreach (var item in remote_files)
                                        {
                                            string pure_path   = item.Substring(remote_path_len, item.Length - remote_path_len);
                                            string target_path = Path.Combine(binary_path_temp_remote, pure_path);
                                            XDirectory.CreateIfNotExists(Path.GetDirectoryName(target_path));
                                            File.Copy(item, target_path);
                                        }
                                    }
                                }
                            }
                            else
                            {
                                string   group_path     = VFSEditorUtil.Get_ExtensionGroupFolderPath_InSourcePackages(platform_name, branch.ExtensionGroupName);
                                int      group_path_len = group_path.Length + 1;
                                string[] group_files    = Directory.GetFiles(group_path, "*.*", SearchOption.AllDirectories);
                                if (group_files != null && group_files.Length > 0)
                                {
                                    total_count++;
                                    ArrayUtil.RemoveDuplicationElements(ref group_files);
                                    foreach (var item in group_files)
                                    {
                                        string pure_path   = item.Substring(group_path_len, item.Length - group_path_len);
                                        string target_path = Path.Combine(binary_path_temp, pure_path);
                                        XDirectory.CreateIfNotExists(Path.GetDirectoryName(target_path));
                                        File.Copy(item, target_path);
                                    }
                                }
                            }

                            long zip_counter   = 0;
                            int  zip_counter_t = 0;

                            //打包
                            string zip_file_path = Path.Combine(binary_path, VFSEditorConst.VFS_VERSION_AssetsBinary_Zip_Name);
                            ZipUtil.ZipDirectory(binary_path_temp, zip_file_path, fileName =>
                            {
                                if (log || dialog)
                                {
                                    zip_counter++;
                                    if (total_count > 100)
                                    {
                                        zip_counter_t++;
                                        if (zip_counter_t >= 20)
                                        {
                                            zip_counter_t = 0;
                                            if (log)
                                            {
                                                Debug.Log($"    Create Zip: {zip_counter}/{total_count}");
                                            }
                                            if (dialog)
                                            {
                                                EditorUtility.DisplayProgressBar("Create Zip", $"{zip_counter}/{total_count}\n{fileName}", zip_counter / total_count);
                                            }
                                        }
                                    }
                                    else
                                    {
                                        if (log)
                                        {
                                            Debug.Log($"    Create Zip: {zip_counter}/{total_count} : {fileName}");
                                        }
                                        if (dialog)
                                        {
                                            EditorUtility.DisplayProgressBar("Create Zip", $"{zip_counter}/{total_count}\n{fileName}", zip_counter / total_count);
                                        }
                                    }
                                }
                            });

                            if (isMainPackage)
                            {
                                string zip_file_path_remote = Path.Combine(binary_path, VFSEditorConst.VFS_VERSION_AssetsBinary_REMOTE_Zip_Name);
                                zip_counter   = 0;
                                zip_counter_t = 0;
                                ZipUtil.ZipDirectory(binary_path_temp_remote, zip_file_path_remote, fileName =>
                                {
                                    if (log || dialog)
                                    {
                                        zip_counter++;
                                        if (total_count > 100)
                                        {
                                            zip_counter_t++;
                                            if (zip_counter_t >= 20)
                                            {
                                                zip_counter_t = 0;
                                                if (log)
                                                {
                                                    Debug.Log($"    Create Zip: {zip_counter}/{total_count}");
                                                }
                                                if (dialog)
                                                {
                                                    EditorUtility.DisplayProgressBar("Create Zip", $"{zip_counter}/{total_count}\n{fileName}", zip_counter / total_count);
                                                }
                                            }
                                        }
                                        else
                                        {
                                            if (log)
                                            {
                                                Debug.Log($"    Create Zip: {zip_counter}/{total_count} : {fileName}");
                                            }
                                            if (dialog)
                                            {
                                                EditorUtility.DisplayProgressBar("Create Zip", $"{zip_counter}/{total_count}\n{fileName}", zip_counter / total_count);
                                            }
                                        }
                                    }
                                });
                            }

                            if (dialog)
                            {
                                EditorUtility.ClearProgressBar(); //上面这个应该是同步方法,不会有时间错乱。(吧
                            }
                            //删除temp
                            XDirectory.DeleteIfExists(binary_path_temp);
                            XDirectory.DeleteIfExists(binary_path_temp_remote);
                        }
                        catch (Exception e)
                        {
                            flag_process_error = true;
                            XDirectory.DeleteIfExists(binary_path);
                            throw e;
                        }
                    }

                    if (!flag_process_error)
                    {
                        //登记到索引
                        var vr = new VersionRecord()
                        {
                            versionCode = versionCode,
                            versionName = versionName,
                            desc        = versionDesc,
                            build_id    = build_id
                        };
                        //记录版本
                        branch.AddVersion(ref vr);

                        //保存版本索引
                        SaveBranchFile(ref branch);
                    }
                }
            }
        }
Example #7
0
        private void RefreshData_Left_list()
        {
            if (mLeft_Select_Platform == null)
            {
                return;
            }
            var    platform_name             = XPlatformUtil.GetNameText(mLeft_Select_Platform.Value);
            string source_packages_root_path = VFSEditorUtil.GetSourcePackagesFolderPath(platform_name);
            string package_stream_root_path  = VFSUtil.GetPackagesRootFolderInStreamingAssets(platform_name);

            //检查,StreamingAssets
            if (mDict_MainPackage_SourcePackage[mLeft_Select_Platform.Value] && mDict_MainPackage_StreamingAssets[mLeft_Select_Platform.Value])
            {
                //两边都有,我们来看看两边的build_id是否一致
                string build_info_source_path = VFSUtil.GetMainPackage_BuildInfo_Path(source_packages_root_path);
                string build_info_stream_path = VFSUtil.GetMainPackage_BuildInfo_Path(package_stream_root_path);
                if (File.Exists(build_info_stream_path) && File.Exists(build_info_source_path))
                {
                    try
                    {
                        var build_info_source = JsonUtility.FromJson <TinaX.VFSKitInternal.BuildInfo>(File.ReadAllText(build_info_source_path));
                        var build_info_stream = JsonUtility.FromJson <TinaX.VFSKitInternal.BuildInfo>(File.ReadAllText(build_info_stream_path));

                        if (build_info_source.BuildID != build_info_stream.BuildID)
                        {
                            main_package_not_same = true;
                        }
                    }
                    catch { }
                }
            }
            else
            {
                main_package_not_same = false;
            }

            //扩展组的处理
            mDict_ExtensionGroups_Info.Clear();
            if (mDict_Extensions_SourcePackage[mLeft_Select_Platform.Value])
            {
                string   source_extensions_root_path = VFSUtil.GetExtensionPackageRootFolderInPackages(source_packages_root_path);
                string[] group_names = VFSUtil.GetValidExtensionGroupNames(source_extensions_root_path);
                foreach (var group in group_names)
                {
                    //streamingassets 中存在嘛
                    if (VFSUtil.IsValidExtensionPackage(VFSUtil.GetExtensionGroupFolder(package_stream_root_path, group)))
                    {
                        //存在,检查build_id
                        string build_id_path_source = VFSUtil.GetExtensionGroup_BuildInfo_Path(source_packages_root_path, group);
                        string build_id_path_stream = VFSUtil.GetExtensionGroup_BuildInfo_Path(package_stream_root_path, group);
                        try
                        {
                            var b_info_source = JsonUtility.FromJson <TinaX.VFSKitInternal.BuildInfo>(File.ReadAllText(build_id_path_source));
                            var b_info_stream = JsonUtility.FromJson <TinaX.VFSKitInternal.BuildInfo>(File.ReadAllText(build_id_path_stream));
                            if (b_info_source.BuildID == b_info_stream.BuildID)
                            {
                                mDict_ExtensionGroups_Info.Add(group, 2);
                            }
                            else
                            {
                                mDict_ExtensionGroups_Info.Add(group, 1);
                            }
                        }
                        catch { }
                        if (!mDict_ExtensionGroups_Info.ContainsKey(group))
                        {
                            mDict_ExtensionGroups_Info.Add(group, 2);
                        }
                    }
                    else
                    {
                        // 不存在
                        mDict_ExtensionGroups_Info.Add(group, 0);
                    }
                }
            }


            mFlag_RefreshData_left_platform = mLeft_Select_Platform;
            mFlag_RefreshData_left          = true;
        }
Example #8
0
        /// <summary>
        /// 准备GUI需要用到的数据
        /// </summary>
        private void RefreshDatas()
        {
            source_packages_counter = 0;
            if (mDict_MainPackage_SourcePackage == null)
            {
                mDict_MainPackage_SourcePackage = new Dictionary <XRuntimePlatform, bool>();
            }
            else
            {
                mDict_MainPackage_SourcePackage.Clear();
            }

            if (mDict_MainPackage_StreamingAssets == null)
            {
                mDict_MainPackage_StreamingAssets = new Dictionary <XRuntimePlatform, bool>();
            }
            else
            {
                mDict_MainPackage_StreamingAssets.Clear();
            }

            if (mDict_Extensions_SourcePackage == null)
            {
                mDict_Extensions_SourcePackage = new Dictionary <XRuntimePlatform, bool>();
            }
            else
            {
                mDict_Extensions_SourcePackage.Clear();
            }

            if (mDict_Extensions_StreamingAssets == null)
            {
                mDict_Extensions_StreamingAssets = new Dictionary <XRuntimePlatform, bool>();
            }
            else
            {
                mDict_Extensions_StreamingAssets.Clear();
            }

            foreach (XRuntimePlatform platform in Enum.GetValues(typeof(XRuntimePlatform)))
            {
                string platform_name = XPlatformUtil.GetNameText(platform);

                //source packages
                string source_packages_path = VFSEditorUtil.GetSourcePackagesFolderPath(platform_name);
                mDict_MainPackage_SourcePackage.Add(platform, VFSEditorUtil.IsValid_MainPackage_InPackages(source_packages_path));
                mDict_Extensions_SourcePackage.Add(platform, VFSEditorUtil.IsAnyValidExtensionGroup_InPackages(source_packages_path));
                if (mDict_MainPackage_SourcePackage[platform] || mDict_Extensions_SourcePackage[platform])
                {
                    source_packages_counter++;
                }

                //streamingassets
                string packages_stream_path = VFSUtil.GetPackagesRootFolderInStreamingAssets(platform_name);
                mDict_MainPackage_StreamingAssets.Add(platform, VFSEditorUtil.IsValid_MainPackage_InPackages(packages_stream_path, true));
                mDict_Extensions_StreamingAssets.Add(platform, VFSEditorUtil.IsAnyValidExtensionGroup_InPackages(packages_stream_path));
                if (mDict_MainPackage_StreamingAssets[platform] || mDict_Extensions_StreamingAssets[platform])
                {
                    packages_stream_counter++;
                }
            }

            mFlag_RefreshData = true;
        }
Example #9
0
        private void OnGUI()
        {
            if (!mFlag_RefreshData)
            {
                this.RefreshDatas();
            }

            EditorGUILayout.BeginHorizontal(GUILayout.Width(width_total));
            //左边列表-source packages
            EditorGUILayout.BeginVertical(mStyle_box, GUILayout.Width(width_left_area));
            GUILayout.Label("Source Packages:");
            if (source_packages_counter > 0)
            {
                v2_list_left = EditorGUILayout.BeginScrollView(v2_list_left);
                foreach (var item in mDict_MainPackage_SourcePackage)
                {
                    if (item.Value || mDict_Extensions_SourcePackage[item.Key])
                    {
                        if (mLeft_Select_Platform != null && mLeft_Select_Platform == item.Key)
                        {
                            GUILayout.Label($"[{item.Key.ToString()}]", mStyle_select_label);
                        }
                        else
                        {
                            if (GUILayout.Button(item.Key.ToString()))
                            {
                                mLeft_Select_Platform = item.Key;
                            }
                        }
                    }
                }
                EditorGUILayout.EndScrollView();
            }
            else
            {
                GUILayout.FlexibleSpace();
                GUILayout.Label(IsChinese ? "没有任何已构建的资源" : "No any built files", mStyle_center_large_label);
                GUILayout.FlexibleSpace();
            }


            EditorGUILayout.EndVertical();

            //中间
            EditorGUILayout.BeginVertical(GUILayout.Width(width_center_area));

            v2_list_center = EditorGUILayout.BeginScrollView(v2_list_center);
            //中间-source packages
            EditorGUILayout.BeginVertical(mStyle_box_center, GUILayout.MinHeight((this.position.height - 25) / 2));
            if (mLeft_Select_Platform == null)
            {
                GUILayout.FlexibleSpace();
                GUILayout.Label(@"(_ _)。゜zzZ");
                GUILayout.FlexibleSpace();
            }
            else
            {
                if (!mFlag_RefreshData_left || mFlag_RefreshData_left_platform == null || mFlag_RefreshData_left_platform.Value != mLeft_Select_Platform.Value)
                {
                    RefreshData_Left_list();
                }
                string platform_name = XPlatformUtil.GetNameText(mLeft_Select_Platform.Value);

                GUILayout.Label(IsChinese ? "已构建的资源" : "Built Assets");
                GUILayout.Label((IsChinese ? "平台:" : "Platform: ") + mLeft_Select_Platform.ToString() + " / " + platform_name);
                if (mDict_MainPackage_SourcePackage[mLeft_Select_Platform.Value])
                {
                    if (!mDict_MainPackage_StreamingAssets[mLeft_Select_Platform.Value])
                    {
                        //source有,stream没有,显示复制选项
                        if (GUILayout.Button(IsChinese?"复制 主包 到StreamingAssets":"Copy Main Package To StreamingAssets"))
                        {
                            VFSEditorUtil.CopyToStreamingAssets(VFSEditorUtil.GetSourcePackagesFolderPath(platform_name), platform_name, false, true);
                            AssetDatabase.Refresh();
                            RefreshDatas();
                        }

                        //source有,stream没有,显示复制选项
                        if (GUILayout.Button(IsChinese ? "复制 全部 到StreamingAssets" : "Copy All Packages To StreamingAssets"))
                        {
                            VFSEditorUtil.CopyToStreamingAssets(VFSEditorUtil.GetSourcePackagesFolderPath(platform_name), platform_name, false, false);
                            AssetDatabase.Refresh();
                            RefreshDatas();
                        }
                    }
                    else
                    {
                        if (main_package_not_same)
                        {
                            EditorGUILayout.HelpBox(IsChinese?"StreamingAssets有 主包 资源,但与构建目录中的资源不一致。": "StreamingAssets has the main package resource, but it is not consistent with the resources in the build directory.", MessageType.None);
                            //source有,stream没有,显示复制选项
                            if (GUILayout.Button(IsChinese ? "复制 主包 到StreamingAssets" : "Copy Main Package To StreamingAssets"))
                            {
                                VFSEditorUtil.CopyToStreamingAssets(VFSEditorUtil.GetSourcePackagesFolderPath(platform_name), platform_name, false, true);
                                AssetDatabase.Refresh();
                                RefreshDatas();
                            }
                        }
                    }
                }
                if (mDict_Extensions_SourcePackage[mLeft_Select_Platform.Value])
                {
                    if (mDict_ExtensionGroups_Info.Count > 0)
                    {
                        GUILayout.Space(5);
                        foreach (var item in mDict_ExtensionGroups_Info)
                        {
                            if (item.Value != 2)
                            {
                                if (GUILayout.Button(IsChinese ? $"复制扩展组 {item.Key} 到StreamingAssets" : $"Copy Extension Group \"{item.Key}\" To StreamingAsssets"))
                                {
                                    string extension_group_source_path = VFSUtil.GetExtensionGroupFolder(VFSEditorUtil.GetSourcePackagesFolderPath(platform_name), item.Key);
                                    VFSEditorUtil.CopyExtensionPackageToSreamingAssets(extension_group_source_path, platform_name, item.Key);
                                    AssetDatabase.Refresh();
                                    RefreshDatas();
                                    RefreshData_Left_list();
                                    Refresh_Right_list();
                                }
                            }
                        }
                    }
                }
            }
            EditorGUILayout.EndVertical();
            GUILayout.Space(10);
            //中间-streamingassets
            EditorGUILayout.BeginVertical(mStyle_box_center, GUILayout.MinHeight((this.position.height - 25) / 2));
            if (mRight_Select_Platform == null)
            {
                GUILayout.FlexibleSpace();
                GUILayout.Label(@"(๑•̀ㅂ•)و✧́");
                GUILayout.FlexibleSpace();
            }
            else
            {
                GUILayout.Label("StreamingAssets");
                GUILayout.Label((IsChinese ? "平台:" : "Platform: ") + mRight_Select_Platform.ToString() + " / " + XPlatformUtil.GetNameText(mRight_Select_Platform.Value));
                if (GUILayout.Button(IsChinese ? "删除资源" : "Delete Assets"))
                {
                    if (EditorUtility.DisplayDialog("sure?", IsChinese?"确定要删除吗":"Are you sure to delete?", IsChinese ? "删它!" : "Delete", IsChinese ? "取消" : "Cancel"))
                    {
                        VFSEditorUtil.DeletePackagesFromStreamingAssets(XPlatformUtil.GetNameText(mRight_Select_Platform.Value));
                        mDict_Extensions_StreamingAssets[mRight_Select_Platform.Value]  = false;
                        mDict_MainPackage_StreamingAssets[mRight_Select_Platform.Value] = false;
                        mRight_Select_Platform  = null;
                        mFlag_RefreshData_right = false;
                        AssetDatabase.Refresh();
                        RefreshDatas();
                        RefreshData_Left_list();
                    }
                }
            }
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndScrollView();

            EditorGUILayout.EndVertical();

            //右边
            EditorGUILayout.BeginVertical(mStyle_box, GUILayout.Width(width_right_area));
            GUILayout.Label("StreamingAssets:");
            if (packages_stream_counter > 0)
            {
                v2_list_right = EditorGUILayout.BeginScrollView(v2_list_right);
                foreach (var item in mDict_MainPackage_StreamingAssets)
                {
                    if (item.Value || mDict_Extensions_StreamingAssets[item.Key])
                    {
                        if (mRight_Select_Platform != null && mRight_Select_Platform == item.Key)
                        {
                            GUILayout.Label($"[{item.Key.ToString()}]", mStyle_select_label);
                        }
                        else
                        {
                            if (GUILayout.Button(item.Key.ToString()))
                            {
                                mRight_Select_Platform = item.Key;
                            }
                        }
                    }
                }
                EditorGUILayout.EndScrollView();
            }
            else
            {
                GUILayout.FlexibleSpace();
                GUILayout.Label(IsChinese ? "没有任何有效的的包" : "No any valid packages", mStyle_center_large_label);
                GUILayout.FlexibleSpace();
            }

            EditorGUILayout.EndVertical();


            EditorGUILayout.EndHorizontal();
        }
Example #10
0
        private void OnGUI()
        {
            EditorGUILayout.BeginHorizontal();

            //左边栏,分支列表
            #region 分支列表

            EditorGUILayout.BeginVertical(GUILayout.Width(branchListAreaWidth));
            //标题
            EditorGUILayout.LabelField(IsChinese ? "版本分支" : "Version branches");
            EditorGUILayout.BeginVertical(style_branchList);

            if (mBranchNames == null || mBranchNames.Length == 0)
            {
                GUILayout.FlexibleSpace();
                GUILayout.Label(IsChinese ? "没有分支信息" : "No branch info.", style_common_list_center_tips_label);
                if (GUILayout.Button(IsChinese?"创建新分支":"Create One"))
                {
                    CreateBranchGUI.OpenUI();
                }
                GUILayout.FlexibleSpace();
            }
            else
            {
                v2_scroll_branch_list = EditorGUILayout.BeginScrollView(v2_scroll_branch_list);

                foreach (var item in mBranchNames)
                {
                    string branchName = item;
                    if (!mSelectBranchName.IsNullOrEmpty() && mSelectBranchName == item)
                    {
                        GUILayout.Label(item, style_branch_list_selected);
                    }
                    else
                    {
                        if (GUILayout.Button(item))
                        {
                            mCurSelectVersion = null;
                            mCurSelectVersion_InBranchName = null;
                            //获取数据
                            if (VFSManagerEditor.VersionManager.TryGetVersionBranch(branchName, out mSelectedBranchObj))
                            {
                                mSelectBranchName = branchName;
                            }
                            else
                            {
                                this.ShowNotification(new GUIContent(IsChinese?$"获取分支“{branchName}”的信息失败":$"Faild to get infos by branch name: {branchName}"));
                            }
                        }
                    }
                }

                EditorGUILayout.EndScrollView();

                GUILayout.BeginHorizontal();
                if (GUILayout.Button("Create", GUILayout.Width(65)))
                {
                    CreateBranchGUI.OpenUI();
                }
                if (mSelectBranchName != null && mSelectedBranchObj != null)
                {
                    if (GUILayout.Button("Delete", GUILayout.Width(65)))
                    {
                        if (EditorUtility.DisplayDialog(IsChinese ? "确定吗?" : "Are you sure", IsChinese ? $"您将要删除分支\"{mSelectBranchName}\"\n继续删除操作将意味着你将失去该分支下的所有版本记录和二进制数据\n并且该操作是不可撤销的,真的要继续吗?" : $"You are about to delete branch \"{mSelectBranchName}\"\nContinuing the delete operation will mean that you will lose all version records and binary data under this branch and the operation is irrevocable. \nDo you really want to continue?", IsChinese ? "继续删除" : "Delete It", IsChinese ? "取消" : "Cancel"))
                        {
                            if (EditorUtility.DisplayDialog(IsChinese ? "二次确认" : "Ask Again", IsChinese ? $"您将要删除分支\"{mSelectBranchName}\"\n继续删除操作将意味着你将失去该分支下的所有版本记录和二进制数据\n并且该操作是不可撤销的,真的要继续吗?\n这是执行操作前的最后一次询问,该操作不可逆。" : $"You are about to delete branch \"{mSelectBranchName}\"\nContinuing the delete operation will mean that you will lose all version records and binary data under this branch and the operation is irrevocable. \nDo you really want to continue?\nThis is the last inquiry before performing the operation", IsChinese ? "继续删除" : "Delete It", IsChinese ? "取消" : "Cancel"))
                            {
                                VFSManagerEditor.VersionManager.RemoveBranch(mSelectBranchName);
                                mBranchNames       = VFSManagerEditor.VersionManager.GetBranchNames();
                                mSelectedBranchObj = null;
                                mSelectBranchName  = null;
                            }
                        }
                    }
                }
                GUILayout.EndHorizontal();
            }

            EditorGUILayout.EndVertical();
            GUILayout.Space(4);
            EditorGUILayout.EndVertical();
            #endregion

            #region 版本列表
            EditorGUILayout.BeginVertical(GUILayout.Width(versionListAreaWidth));
            //标题
            EditorGUILayout.LabelField(IsChinese ? "版本列表" : "Versions list");
            EditorGUILayout.BeginVertical(style_versionList);
            if (mSelectedBranchObj == null || mSelectBranchName == null)
            {
                GUILayout.FlexibleSpace();
                GUILayout.Label(IsChinese ? "请选择分支" : "Please select a branch", style_common_list_center_tips_label);
                GUILayout.FlexibleSpace();
            }
            else
            {
                if (mSelectedBranchObj.VersionRecords_ReadWrite.Count == 0)
                {
                    GUILayout.FlexibleSpace();
                    GUILayout.Label(IsChinese ? "没有版本信息记录" : "No version records", style_common_list_center_tips_label);
                    GUILayout.FlexibleSpace();
                }
                else
                {
                    v2_scroll_version_list = EditorGUILayout.BeginScrollView(v2_scroll_version_list);
                    foreach (var item in mSelectedBranchObj.VersionRecords_ReadWrite)
                    {
                        if (mCurSelectVersion != null && mCurSelectVersion.Value.versionCode == item.versionCode && mCurSelectVersion_InBranchName == mSelectedBranchObj.BranchName)
                        {
                            GUILayout.Label($"{item.versionCode} - {item.versionName}", style_branch_list_selected);
                        }
                        else
                        {
                            if (GUILayout.Button($"{item.versionCode} - {item.versionName}"))
                            {
                                mCurSelectVersion = item;
                                mCurSelectVersion_InBranchName = mSelectedBranchObj.BranchName;
                            }
                        }
                    }

                    EditorGUILayout.EndScrollView();
                }
            }

            EditorGUILayout.EndVertical();

            EditorGUILayout.EndVertical();
            #endregion

            #region 分支详情和版本操作

            EditorGUILayout.BeginVertical(GUILayout.Width(position.width - branchListAreaWidth - versionListAreaWidth));

            GUILayout.Label(IsChinese ? "分支信息" : "branch info");
            if (mSelectBranchName != null && mSelectedBranchObj != null)
            {
                //分支名
                GUILayout.Label((IsChinese ? "分支名:" : "Branch Name : ") + mSelectedBranchObj.BranchName);
                //平台
                GUILayout.Label((IsChinese ? "目标平台:" : "Platform : ") + mSelectedBranchObj.Platform.ToString());
                //分支类型
                GUILayout.Label((IsChinese ? "分支类型:" : "Branch Type : ") + mSelectedBranchObj.BType.ToString());
                if (mSelectedBranchObj.BType == VersionBranch.BranchType.ExtensionGroup)
                {
                    GUILayout.Label((IsChinese ? "扩展组名:" : "Extension Group Name : ") + mSelectedBranchObj.ExtensionGroupName.ToString());
                }
                //描述
                GUILayout.Label((IsChinese ? "分支描述:" : "Branch Desc : "));
                GUILayout.Label(mSelectedBranchObj.Desc);
                EditorGUIUtil.HorizontalLine();



                //------------版本列表操作----
                if (GUILayout.Button("创建新版本"))
                {
                    CreateVersionRecordGUI.BranchName = mSelectBranchName;
                    CreateVersionRecordGUI.OpenUI();
                }
                EditorGUIUtil.HorizontalLine();

                //------------具体版本操作------
                if (mSelectedBranchObj.VersionRecords_ReadWrite.Count > 0)
                {
                    if (mCurSelectVersion != null || mCurSelectVersion_InBranchName == mSelectBranchName)
                    {
                        //版本号
                        EditorGUILayout.BeginHorizontal();
                        GUILayout.Label((IsChinese ? "版本:" : "Version: ") + mCurSelectVersion.Value.versionCode.ToString());
                        //GUILayout.Label(mCurSelectVersion.Value.versionCode.ToString());
                        EditorGUILayout.EndHorizontal();

                        //版本名
                        EditorGUILayout.BeginHorizontal();
                        GUILayout.Label((IsChinese ? "版本名:" : "Version Name: ") + mCurSelectVersion.Value.versionName);
                        //GUILayout.Label(mCurSelectVersion.Value.versionName);
                        EditorGUILayout.EndHorizontal();

                        //概述
                        EditorGUILayout.BeginHorizontal();
                        GUILayout.Label((IsChinese ? "描述:" : "Desc: ") + mCurSelectVersion.Value.desc);
                        //GUILayout.Label(mCurSelectVersion.Value.desc);
                        EditorGUILayout.EndHorizontal();

                        long versionCode = mCurSelectVersion.Value.versionCode;

                        if (GUILayout.Button(IsChinese?"浏览版本数据": "View version data"))
                        {
                            string data_path = VFSEditorUtil.GetVersionDataFolderPath_InProjectVersion(mSelectBranchName, versionCode);
                            if (System.IO.Directory.Exists(data_path))
                            {
                                var uri = new Uri(data_path);
                                Application.OpenURL(uri.ToString());
                            }
                        }

                        string binary_path = VFSEditorUtil.Get_AssetsBinaryFolderPath_InVersion(mSelectBranchName, versionCode);
                        if (System.IO.Directory.Exists(binary_path))
                        {
                            if (GUILayout.Button(IsChinese?"浏览二进制数据":"View binary files"))
                            {
                                var uri = new Uri(binary_path);
                                Application.OpenURL(uri.ToString());
                            }
                        }

                        //制作补丁
                        //EditorGUILayout.Space();
                        if (GUILayout.Button(IsChinese ? "制作补丁" : "Make Patch"))
                        {
                            List <string> display_list     = new List <string>();
                            List <long>   versioncode_list = new List <long>();

                            foreach (var item in mSelectedBranchObj.VersionRecords_ReadWrite)
                            {
                                display_list.Add($"[{item.versionCode}] {item.versionName}");
                                versioncode_list.Add(item.versionCode);
                            }

                            ScriptableSingleton <MakePatchGUIParamCache> .instance.branchName           = mSelectedBranchObj.BranchName;
                            ScriptableSingleton <MakePatchGUIParamCache> .instance.current_version      = mCurSelectVersion.Value.versionCode;
                            ScriptableSingleton <MakePatchGUIParamCache> .instance.version_code_list    = versioncode_list.ToArray();
                            ScriptableSingleton <MakePatchGUIParamCache> .instance.version_display_list = display_list.ToArray();

                            MakePatchGUI.OpenUI();
                        }

                        //删除版本
                        EditorGUILayout.Space();
                        if (GUILayout.Button(IsChinese?"删除该版本":"Delete this version"))
                        {
                            if (EditorUtility.DisplayDialog(IsChinese ? "删除吗?" : "Delete it?", IsChinese ? $"你将删除该记录,并且不可恢复\n版本号:{versionCode}, 版本名: {mCurSelectVersion.Value.versionName}" : $"You will delete the record and it is not recoverable\nVersion:{versionCode}, Version Name: {mCurSelectVersion.Value.versionName}", IsChinese ? "删它!" : "Delete", IsChinese ? "别删" : "Cancel"))
                            {
                                VFSManagerEditor.VersionManager.RemoveProfileRecord(ref mSelectedBranchObj, versionCode);
                                mCurSelectVersion_InBranchName = null;
                                mCurSelectVersion = null;
                            }
                        }
                    }
                }
                else
                {
                }
            }
            else
            {
                GUILayout.Label(" - ");
            }


            EditorGUILayout.EndVertical();
            #endregion


            EditorGUILayout.EndHorizontal();
        }
Example #11
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="root_path">root_path下面应该就是"vfs_root","vfs_data"之类的文件</param>
 public void CopyToStreamingAssets(string root_path, string platform_name)
 {
     Debug.Log("    copy To \"StreamingAssets\"");
     VFSEditorUtil.CopyToStreamingAssets(root_path, platform_name);
 }
Example #12
0
        private void OnGUI()
        {
            GUILayout.BeginVertical(style_body);

            #region Profile 选择

            if (xprofiles == null || (select_xprofile - 1) > xprofiles.Length)
            {
                refreshXprofilesCacheData();
            }
            if (mDevelopMode)
            {
                GUILayout.Label("[Develop Mode]", style_warning);
            }
            GUILayout.BeginHorizontal(style_profile_selector);
            GUILayout.Label("Profile:", GUILayout.Width(55));

            //select_xprofile = EditorGUILayout.Popup(select_xprofile, xprofiles);
            GUILayout.Label(xprofiles[select_xprofile]);
            if (GUILayout.Button(VFSBuilderI18N.SwitchProfile, GUILayout.Width(50)))
            {
                SettingsService.OpenProjectSettings(XEditorConst.ProjectSetting_CorePath);
            }
            GUILayout.EndHorizontal();

            #endregion
            if (xprofiles != null && xprofiles.Length > 0)
            {
                cur_select_xprofile_name = xprofiles[select_xprofile];
            }

            #region 平台选择
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label(VFSBuilderI18N.PlatformTarget, GUILayout.MaxWidth(100));
            cur_select_platform = (XRuntimePlatform)EditorGUILayout.EnumPopup(cur_select_platform);
            EditorGUILayout.EndHorizontal();
            #endregion

            #region 严格模式
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label(VFSBuilderI18N.strictMode, GUILayout.Width(100));
            cur_strictMode = EditorGUILayout.Toggle(cur_strictMode);
            EditorGUILayout.EndHorizontal();
            #endregion

            #region 压缩设置
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label(VFSBuilderI18N.AssetCompressType, GUILayout.MaxWidth(100));
            cur_select_compress = (AssetCompressType)EditorGUILayout.EnumPopup(cur_select_compress);
            EditorGUILayout.EndHorizontal();
            #endregion

            #region  制到StreamingAssets
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label(VFSBuilderI18N.CopyToStramingAssetPath, GUILayout.MaxWidth(200));
            cur_copyToStreamingAssetFolder = EditorGUILayout.Toggle(cur_copyToStreamingAssetFolder);
            EditorGUILayout.EndHorizontal();
            #endregion

            #region 在结束前清理AB标记
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label(VFSBuilderI18N.ClearAllABSignBeforeStart);
            cur_clearAllABSign = EditorGUILayout.Toggle(cur_clearAllABSign);
            EditorGUILayout.EndHorizontal();
            GUILayout.Label(VFSBuilderI18N.ClearAllABSignBeforeStart_Tips, EditorStyles.helpBox);
            #endregion

            #region 在结束后清理AB标记
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label(VFSBuilderI18N.ClearAllABSignAfterFinish);
            cur_clearAllABSignAfterFinish = EditorGUILayout.Toggle(cur_clearAllABSignAfterFinish);
            EditorGUILayout.EndHorizontal();
            #endregion

            #region 清理输出目录
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label(VFSBuilderI18N.ClearOutputFolders);
            cur_ClearOutputFolder = EditorGUILayout.Toggle(cur_ClearOutputFolder);
            EditorGUILayout.EndHorizontal();
            #endregion

            #region 强制重构建资源
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label(VFSBuilderI18N.ForceRebuild);
            cur_ForceRebuild = EditorGUILayout.Toggle(cur_ForceRebuild);
            EditorGUILayout.EndHorizontal();
            #endregion

            #region 管线
            if (mPipeline_ready == false)
            {
                refreshBuildPipline();
            }
            if (mList_pipeline != null && mList_pipeline.Count > 0)
            {
                GUILayout.Space(15);
                TinaXEditor.Utils.EditorGUIUtil.HorizontalLine();
                GUILayout.Label("Builder Pipeline:");
                v2_scroll_pipeline = EditorGUILayout.BeginScrollView(v2_scroll_pipeline);
                foreach (var type in mList_pipeline)
                {
                    if (type.Namespace.IsNullOrEmpty())
                    {
                        GUILayout.Label($"- {type.FullName} [{type.Assembly.ManifestModule.Name}]");
                    }
                    else
                    {
                        GUILayout.Label($"- {type.Namespace}.{type.FullName} [{type.Assembly.ManifestModule.Name}]");
                    }
                }
                EditorGUILayout.EndScrollView();
            }

            #endregion

            //#region Preview
            //GUILayout.BeginVertical(style_preview);
            //GUILayout.Label("Build Priview", EditorStyles.centeredGreyMiniLabel);
            //GUILayout.Label("Build Group:");
            //GUILayout.FlexibleSpace();
            //GUILayout.EndVertical();

            //#endregion
            EditorGUILayout.Space();

            if (GUILayout.Button("Build", style_btn_build))
            {
                runBuild();
            }
            if (GUILayout.Button(VFSBuilderI18N.RemoveAllAssetBundleSign))
            {
                if (EditorUtility.DisplayDialog("Clear?", "Are you sure?", "yes", "no"))
                {
                    VFSEditorUtil.RemoveAllAssetbundleSigns(true);
                }
            }
            if (GUILayout.Button(VFSBuilderI18N.CreateVersionRecord))
            {
                CreateVersionRecordGUI.VFS_Platform = cur_select_platform;
                CreateVersionRecordGUI.OpenUI();
            }
            EditorGUILayout.Space();

            GUILayout.EndVertical();
        }
        private void OnGUI()
        {
            //GUILayout.Label("width " + this.position.width + "  height:" + this.position.height);
            EditorGUILayout.BeginVertical();
            GUILayout.Space(10);
            mBranchAndPlatformValid = true;
            #region 版本分支
            if (flag_branchName_from_param)
            {
                //参数指定了分支名
                if (!isBrancNameFromParamValid)
                {
                    //给出的分支名无效
                    GUILayout.FlexibleSpace();
                    GUILayout.Label(IsChinese ? $"出错:指定的分支名 {branchName_from_param} 无效" : $"Error: invalid branch name {branchName_from_param} specified");
                    GUILayout.FlexibleSpace();
                    mBranchAndPlatformValid = false;
                }
                else
                {
                    //使用给定的分支信息继续
                    EditorGUILayout.BeginHorizontal();
                    GUILayout.Label(IsChinese ? "版本分支:" : "Version Branch: ", GUILayout.Width(110));
                    EditorGUILayout.LabelField(branchName_from_param);
                    EditorGUILayout.EndHorizontal();
                }
            }
            else
            {
                //手动选择分支
                if (flag_platform_from_param)
                {
                    //从参数里获取到了平台信息,那么就要根据指定的平台来选择分支
                    if (match_branches_from_param.Count == 0)
                    {
                        mBranchAndPlatformValid = false;
                        GUILayout.Label(IsChinese ? $"没有平台{platform_from_param.ToString()}对应的分支信息" : $"There is no branch info corresponding to platform {platform_from_param.ToString()}");
                    }
                    else
                    {
                        EditorGUILayout.BeginHorizontal();
                        GUILayout.Label(IsChinese ? "版本分支:" : "Version Branch: ", GUILayout.Width(110));
                        mCur_Select_Branch_Index = EditorGUILayout.Popup(mCur_Select_Branch_Index, match_branches_from_param_arr);
                        EditorGUILayout.EndHorizontal();
                        mCurSelectBranchName = match_branches_from_param_arr[mCur_Select_Branch_Index];
                    }
                }
                else
                {
                    if (!mAllBranch_Inited)
                    {
                        mAllBranchNames          = VFSManagerEditor.VersionManager.GetBranchNames();
                        mCur_Select_Branch_Index = 0;
                        mAllBranch_Inited        = true;
                    }
                    if (mAllBranchNames.Length == 0)
                    {
                        mBranchAndPlatformValid = false;
                        GUILayout.Label(IsChinese ? "没有分支信息" : "No Branch Infos");
                    }
                    else
                    {
                        EditorGUILayout.BeginHorizontal();
                        GUILayout.Label(IsChinese ? "版本分支:" : "Version Branch: ", GUILayout.Width(110));
                        mCur_Select_Branch_Index = EditorGUILayout.Popup(mCur_Select_Branch_Index, mAllBranchNames);
                        EditorGUILayout.EndHorizontal();
                        mCurSelectBranchName = mAllBranchNames[mCur_Select_Branch_Index];
                    }
                }
            }
            #endregion

            #region 平台选择
            if (mBranchAndPlatformValid)
            {
                if (flag_platform_from_param)
                {
                    //指定了平台,直接显示
                    EditorGUILayout.BeginHorizontal();
                    GUILayout.Label(IsChinese ? "目标平台" : "Platform :", GUILayout.Width(110));
                    GUILayout.Label(platform_from_param.ToString());
                    EditorGUILayout.EndHorizontal();
                    //由分支决定平台
                    if (mCurBranch == null || mCurBranch.BranchName != mCurSelectBranchName)
                    {
                        VFSManagerEditor.VersionManager.TryGetVersionBranch(mCurSelectBranchName, out mCurBranch);
                    }
                }
                else
                {
                    if (flag_branchName_from_param)
                    {
                        //指定了分支但没指定平台,也直接显示
                        //指定了平台,直接显示
                        EditorGUILayout.BeginHorizontal();
                        GUILayout.Label(IsChinese ? "目标平台" : "Platform :", GUILayout.Width(110));
                        GUILayout.Label(platform_from_param.ToString());
                        EditorGUILayout.EndHorizontal();
                    }
                    else
                    {
                        //由分支决定平台
                        if (mCurBranch == null || mCurBranch.BranchName != mCurSelectBranchName)
                        {
                            VFSManagerEditor.VersionManager.TryGetVersionBranch(mCurSelectBranchName, out mCurBranch);
                        }
                        EditorGUILayout.BeginHorizontal();
                        GUILayout.Label(IsChinese ? "目标平台" : "Platform", GUILayout.Width(110));
                        GUILayout.Label(mCurBranch.Platform.ToString());
                        EditorGUILayout.EndHorizontal();
                    }
                }

                if (IsSourcePackagesValidByCurBranch_BranchName == null || IsSourcePackagesValidByCurBranch_BranchName != mCurBranch.BranchName)
                {
                    string platformName = XPlatformUtil.GetNameText(mCurBranch.Platform);
                    string source_packages_folder_path = Path.Combine(VFSEditorConst.PROJECT_VFS_SOURCE_PACKAGES_ROOT_PATH, platformName);
                    if (mCurBranch.BType == VersionBranch.BranchType.MainPackage)
                    {
                        IsSourcePackagesValidByCurBranch = VFSEditorUtil.IsValid_MainPackage_InPackages(source_packages_folder_path);
                    }
                    else
                    {
                        IsSourcePackagesValidByCurBranch = VFSEditorUtil.IsValid_ExtensionGroup_InPackages(source_packages_folder_path, mCurBranch.ExtensionGroupName);
                    }

                    IsSourcePackagesValidByCurBranch_BranchName = mCurBranch.BranchName;
                }

                if (!IsSourcePackagesValidByCurBranch)
                {
                    EditorGUILayout.HelpBox(IsChinese ? "没有适合当前分支的已构建文件,请先构建资源。" : "There are no built files for the current branch, please build assets first.", MessageType.Error);
                    mBranchAndPlatformValid = false;
                }
            }
            #endregion

            #region 杂七杂八信息
            if (mBranchAndPlatformValid)
            {
                //先算一下版本号
                if (curMaxVersionCode_BranchName == null || curMaxVersionCode_BranchName != mCurBranch.BranchName)
                {
                    var max_version = mCurBranch.GetMaxVersion();
                    if (max_version == null)
                    {
                        curMaxVersionCode = -1;
                    }
                    else
                    {
                        curMaxVersionCode = max_version.Value.versionCode;
                    }
                    curMaxVersionCode_BranchName = mCurBranch.BranchName;
                }

                //版本号
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label(IsChinese ? "版本号:" : "Version Code:", GUILayout.Width(110));
                mCurVersionCode = EditorGUILayout.LongField(mCurVersionCode);
                EditorGUILayout.EndHorizontal();
                if (mCurVersionCode <= curMaxVersionCode)
                {
                    mCurVersionCode = curMaxVersionCode + 1;
                }

                //版本名
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label(IsChinese ? "版本名:" : "Version Name:", GUILayout.Width(110));
                mCurVersionName = EditorGUILayout.TextField(mCurVersionName);
                EditorGUILayout.EndHorizontal();

                //版本描述
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label(IsChinese ? "版本描述:" : "Description:", GUILayout.Width(110));
                mCurVersionDecs = EditorGUILayout.TextArea(mCurVersionDecs);
                EditorGUILayout.EndHorizontal();

                GUILayout.Space(5);
                //保存二进制文件
                EditorGUILayout.BeginHorizontal();
                //GUILayout.Label(IsChinese ? "保存二进制文件:" : "Save Binary:", GUILayout.Width(125));
                mCurSaveBinary = EditorGUILayout.Toggle(IsChinese ? "保存二进制文件:" : "Save Binary:", mCurSaveBinary);
                EditorGUILayout.EndHorizontal();
                if (mCurSaveBinary)
                {
                    if (IsChinese)
                    {
                        EditorGUILayout.HelpBox("该版本记录不仅仅会保存资源的Hash值,同时将会保存所有构建出的资源文件。这会占用较大的磁盘空间。", MessageType.Info);
                    }
                    else
                    {
                        EditorGUILayout.HelpBox("This version record will not only save the hash info of the resource, but also all the resource files that are built. This will take up a lot of disk space.", MessageType.Info);
                    }
                }
            }

            if (mBranchAndPlatformValid)
            {
                if (GUILayout.Button("Save"))
                {
                    VFSManagerEditor.VersionManager.AddVersionRecord(mCurBranch.BranchName, mCurVersionCode, mCurVersionName, mCurVersionDecs, mCurSaveBinary);
                    EditorUtility.DisplayDialog("Finish", "Finish", "Ok");
                    this.Close();
                }
            }


            #endregion

            EditorGUILayout.EndVertical();
        }