Example #1
0
        //Source packages 是指 VFS打包资源后的输出目录,里面包括"vfs_root","vfs_data"什么的那个目录

        /// <summary>
        /// 检查在给定的根目录下,是否有有效的MainPackage文件
        /// </summary>
        /// <returns></returns>
        internal static bool IsValid_MainPackage_InPackages(string packages_root_path, bool runtime_used = false)
        {
            //检查是否有vfs_root目录
            string vfs_root = VFSUtil.GetMainPackageFolderInPackages(packages_root_path);

            if (!Directory.Exists(vfs_root))
            {
                return(false);
            }
            //检查data目录
            if (!Directory.Exists(VFSUtil.GetDataFolderInPackages(packages_root_path)))
            {
                return(false);
            }
            //检查build_info
            if (!File.Exists(VFSUtil.GetMainPackage_BuildInfo_Path(packages_root_path)))
            {
                return(false);
            }

            if (!runtime_used)
            {
                //检查asset_hash
                if (!File.Exists(VFSEditorUtil.GetMainPackage_AssetsHash_FilePath_InPackages(packages_root_path)))
                {
                    return(false);
                }
                //检查editor build_info
                if (!File.Exists(VFSEditorUtil.Get_EditorBuildInfoPath(packages_root_path)))
                {
                    return(false);
                }
            }

            return(true);
        }
Example #2
0
 /// <summary>
 /// 获取 Source Pakcges 下的 扩展组 的 版本信息 文件路径
 /// </summary>
 /// <param name="platform_name"></param>
 /// <returns></returns>
 public static string Get_ExtensionGroups_PackageVersionFilePath_InSourcePackages(ref string platform_name, ref string groupName)
 {
     return(Path.Combine(VFSUtil.GetExtensionGroupFolder(VFSEditorUtil.GetSourcePackagesFolderPath(platform_name), groupName), VFSConst.PakcageVersionFileName));
 }
Example #3
0
        /// <summary>
        /// 复制到StreamingAssets
        /// </summary>
        /// <param name="packages_root_path">Packages根目录(有vfs_root,vfs_data之类的那个目录)</param>
        /// <param name="platform_name">平台名</param>
        public static void CopyToStreamingAssets(string packages_root_path, string platform_name, bool clearOtherPlatformFiles = false, bool OnlyMainPackage = false)
        {
            VFSEditorUtil.InitVFSFoldersInStreamingAssets(platform_name, clearOtherPlatformFiles);
            var stream_root_path      = Path.Combine(Application.streamingAssetsPath, VFSConst.VFS_STREAMINGASSETS_PATH);
            var project_vfs_root_path = Path.Combine(packages_root_path, VFSConst.VFS_FOLDER_MAIN);

            if (Directory.Exists(project_vfs_root_path))
            {
                string target_vfs_root = Path.Combine(stream_root_path, platform_name, VFSConst.VFS_FOLDER_MAIN);
                XDirectory.DeleteIfExists(target_vfs_root);
                XDirectory.CopyDir(project_vfs_root_path, target_vfs_root);
            }

            if (!OnlyMainPackage)
            {
                var project_vfs_extension_group = Path.Combine(packages_root_path, VFSConst.VFS_FOLDER_EXTENSION);
                if (Directory.Exists(project_vfs_extension_group))
                {
                    string target_vfs_extension = Path.Combine(stream_root_path, platform_name, VFSConst.VFS_FOLDER_EXTENSION);
                    XDirectory.DeleteIfExists(target_vfs_extension);
                    XDirectory.CopyDir(project_vfs_extension_group, target_vfs_extension);
                }
            }

            //Data目录处理----------------------------------------------------------
            //assetBundle hash
            var main_package_assetbundle_hash_files_folder_path = VFSUtil.GetMainPackageAssetBundleHashFilesRootPath(packages_root_path);

            if (Directory.Exists(main_package_assetbundle_hash_files_folder_path))
            {
                string target_path = VFSUtil.GetMainPackageAssetBundleHashFilesRootPath(Path.Combine(stream_root_path, platform_name));
                XDirectory.DeleteIfExists(target_path);
                XDirectory.CopyDir(main_package_assetbundle_hash_files_folder_path, target_path);
            }

            //manifest
            var main_package_manifest_file_folder_path = VFSUtil.GetMainPackage_AssetBundleManifests_Folder(packages_root_path);

            if (Directory.Exists(main_package_manifest_file_folder_path))
            {
                string target_path = VFSUtil.GetMainPackage_AssetBundleManifests_Folder(Path.Combine(stream_root_path, platform_name));
                XDirectory.DeleteIfExists(target_path);
                XDirectory.CopyDir(main_package_manifest_file_folder_path, target_path);
            }
            //build info
            var main_package_build_info = VFSUtil.GetMainPackage_BuildInfo_Path(packages_root_path);

            if (File.Exists(main_package_build_info))
            {
                string target_path = VFSUtil.GetMainPackage_BuildInfo_Path(Path.Combine(stream_root_path, platform_name));
                XFile.DeleteIfExists(target_path);
                XDirectory.CreateIfNotExists(Path.GetDirectoryName(target_path));
                File.Copy(main_package_build_info, target_path);
            }

            //package version info
            var main_package_version_info = VFSUtil.GetMainPackage_VersionInfo_Path(packages_root_path);

            if (File.Exists(main_package_version_info))
            {
                string target_path = VFSUtil.GetMainPackage_VersionInfo_Path(Path.Combine(stream_root_path, platform_name));
                XFile.DeleteIfExists(target_path);
                XDirectory.CreateIfNotExists(Path.GetDirectoryName(target_path));
                File.Copy(main_package_version_info, target_path);
            }

            //vfs config
            var vfs_config_path = VFSUtil.GetVFSConfigFilePath_InPackages(packages_root_path);

            if (File.Exists(vfs_config_path))
            {
                string target_path = VFSUtil.GetVFSConfigFilePath_InPackages(Path.Combine(stream_root_path, platform_name));
                XFile.DeleteIfExists(target_path);
                XDirectory.CreateIfNotExists(Path.GetDirectoryName(target_path));
                File.Copy(vfs_config_path, target_path, true);
            }
        }