/// <summary> /// 通过平台名称获取平台枚举值 /// </summary> /// <param name="platformName"></param> /// <returns></returns> public static EnumPlatform EnumPlatform_GetPlatformEnumByName(string platformName) { var platformEnum = new EnumPlatform(); switch (platformName) { case "统一号源池": platformEnum = EnumPlatform.UniformSourcePool; break; case "床位预约": platformEnum = EnumPlatform.BerthBooking; break; case "手术预约": platformEnum = EnumPlatform.SurgeryBooking; break; case "医技预约": platformEnum = EnumPlatform.MedicalTechBooking; break; case "日间手术预约": platformEnum = EnumPlatform.DaySurgicalBooking; break; } return(platformEnum); }
/// <summary> /// 通过平台枚举值获取平台名称 /// </summary> /// <param name="em"></param> /// <returns></returns> public static string EnumPlatform_GetPlatformNameByEnum(EnumPlatform em) { var platformName = ""; switch (em) { case EnumPlatform.UniformSourcePool: platformName = "统一号源池"; break; case EnumPlatform.BerthBooking: platformName = "床位预约"; break; case EnumPlatform.SurgeryBooking: platformName = "手术预约"; break; case EnumPlatform.MedicalTechBooking: platformName = "医技预约"; break; case EnumPlatform.DaySurgicalBooking: platformName = "日间手术预约"; break; } return(platformName); }
/// <summary> /// 通过平台枚举值获取平台代码 /// </summary> /// <param name="em"></param> /// <returns></returns> public static int EnumPlatform_GetPlatformCodeByEnum(EnumPlatform em) { var platformCode = 0; switch (em) { case EnumPlatform.UniformSourcePool: platformCode = 1; break; case EnumPlatform.BerthBooking: platformCode = 2; break; case EnumPlatform.SurgeryBooking: platformCode = 3; break; case EnumPlatform.MedicalTechBooking: platformCode = 4; break; case EnumPlatform.DaySurgicalBooking: platformCode = 5; break; } return(platformCode); }
public static BuildTarget GetBuildTarget(EnumPlatform platform) { var buildTarget = BuildTarget.NoTarget; switch (platform) { case EnumPlatform.Android: buildTarget = BuildTarget.Android; break; case EnumPlatform.Windows: buildTarget = BuildTarget.StandaloneWindows64; break; case EnumPlatform.iOS: buildTarget = BuildTarget.iOS; break; } return(buildTarget); }
/// <summary> /// /// </summary> /// <param name="pl"></param> /// <param name="log">logging messages</param> /// <param name="xmlContentFile"></param> /// <param name="targetName"></param> /// <param name="mode"></param> /// <returns></returns> public string Compile(EnumPlatform pl, IShowMessage log, string xmlContentFile, string targetName, string mode) { string sError = string.Empty; string targetFolder = Path.Combine(Path.GetDirectoryName(xmlContentFile), string.Format(CultureInfo.InvariantCulture, "bin\\{0}", mode)); XmlDocument doc = new XmlDocument(); doc.Load(xmlContentFile); _root = new WixXmlRoot(doc.DocumentElement, xmlContentFile); _root.Preprocess(targetName, mode, log); sError = WixUtil.start(doc, targetFolder, pl == EnumPlatform.x64 ? "x64" : "x86", log); if (string.IsNullOrEmpty(sError)) { string curId = _root.General.ProductId; doc = new XmlDocument(); doc.Load(xmlContentFile); _root = new WixXmlRoot(doc.DocumentElement, xmlContentFile); _root.General.LastProductId = curId; _root.Postprocess(targetName, mode, log); } return(sError); }
private static double CalculateShareCodePerPlaform(Solution _currentSolution, EnumPlatform _selectedPlatform) { var totalCoreLOC = _currentSolution.Projects.Where(x => x.Platform == EnumPlatform.Core).SelectMany(x => x.Files).Where(x => x.IsUserInterface == false).Sum(x => x.LOC); var platformSpecificLOC = _currentSolution.Projects.Where(x => x.Platform == _selectedPlatform).SelectMany(x => x.Files).Where(x => x.IsUserInterface == false).Sum(x => x.LOC); return(Math.Round(((double)totalCoreLOC / (platformSpecificLOC + totalCoreLOC)) * 100, 2)); }
//资源打包 public static void BuildAssetBundle(EnumPlatform platform) { var buildTarget = EditorXAssetBundle.GetBuildTarget(platform); if (buildTarget == BuildTarget.NoTarget) { return; } var outputBuild = EditorXAssetBundle.GetOutputBuild(platform); XUtilities.MakePathExist(outputBuild); var manifest = BuildPipeline.BuildAssetBundles(outputBuild, BuildAssetBundleOptions.ChunkBasedCompression, buildTarget); var logger = XDebug.CreateMutiLogger(XABConst.Tag); logger.Append("===打包完成==="); foreach (var assetBundle in manifest.GetAllAssetBundles()) { logger.Append(assetBundle); } logger.Log(); /* * 打包完成后,需要检测一下static包是否依赖了hotfix包,这是不允许的! * 最好能在设置包名的时候就检测,但是没有找到简便的方式去检测依赖项, * 这里使用打包完成后的manifest做依赖项检测,以后再说 */ var assetNameConfig = XUtilities.GetOrCreateConfig <XABAssetNameConfig>(XABAssetNameConfig.AssetPath); //-- //打包完成后,将static和hotfix分开目录 XABManifest manifestStatic = new XABManifest(); XABManifest manifestHotfix = new XABManifest(); var outputStatic = EditorXAssetBundle.GetOutputStatic(platform); var outputHotfix = EditorXAssetBundle.GetOutputHotfix(platform); List <string> staticBundleNames = new List <string>(); List <string> hotfixBundleNames = new List <string>(); foreach (var data in assetNameConfig.StaticDatas) { manifestStatic.SetAssetNameLink(data.AssetName, data.AssetBundleName); if (!staticBundleNames.Contains(data.AssetBundleName)) { staticBundleNames.Add(data.AssetBundleName); } } foreach (var data in assetNameConfig.HotfixDatas) { manifestHotfix.SetAssetNameLink(data.AssetName, data.AssetBundleName); if (!hotfixBundleNames.Contains(data.AssetBundleName)) { hotfixBundleNames.Add(data.AssetBundleName); } } //检测依赖关系,不允许跟包资源依赖热更资源 bool dependencyError = false; foreach (var bundleName in staticBundleNames) { var dependencies = manifest.GetAllDependencies(bundleName); //Debug.Log($"{bundleName} 依赖数量 {dependencies.Length}"); foreach (var dependency in dependencies) { //Debug.Log("check " + dependency); if (hotfixBundleNames.Contains(dependency)) { XDebug.LogError(XABConst.Tag, $"static:{bundleName} 依赖 hotfix:{dependency}"); dependencyError = true; } } } if (dependencyError) { EditorUtility.DisplayDialog("错误", "跟包资源不允许依赖更新资源!!\n错误依赖请看控制台打印!!", "OK"); return; } XUtilities.CleanFolder(outputStatic); XUtilities.CleanFolder(outputHotfix); XUtilities.MakePathExist(outputStatic); XUtilities.MakePathExist(outputHotfix); foreach (var bundleName in staticBundleNames) { var src = $"{outputBuild}/{bundleName}"; var dst = $"{outputStatic}/{bundleName}"; File.Copy(src, dst); manifestStatic.SetDependency(bundleName, manifest.GetAllDependencies(bundleName)); } foreach (var bundleName in hotfixBundleNames) { var src = $"{outputBuild}/{bundleName}"; var dst = $"{outputHotfix}/{bundleName}"; File.Copy(src, dst); manifestHotfix.SetDependency(bundleName, manifest.GetAllDependencies(bundleName)); } //将依赖关系写入文件夹 var jsonStatic = JsonUtility.ToJson(manifestStatic); var pathStatic = $"{outputStatic}/manifest.json"; File.WriteAllText(pathStatic, jsonStatic); var jsonHotfix = JsonUtility.ToJson(manifestHotfix); var pathHotfix = $"{outputHotfix}/manifest.json"; File.WriteAllText(pathHotfix, jsonHotfix); }
public static string GetOutputHotfix(EnumPlatform platform) { return($"{GetOutput(platform)}/Hotfix"); }
public static string GetOutputStatic(EnumPlatform platform) { return($"{GetOutput(platform)}/Static"); }
public static string GetOutputBuild(EnumPlatform platform) { return($"{GetOutput(platform)}/Build"); }
//输出路径 public static string GetOutput(EnumPlatform platform) { return($"{Application.dataPath}/../AssetBundles/{platform.ToString()}"); }
public Platforms(EnumPlatform platform) { this.currentPlatform = platform; }