public void Append(string mark, string text) { if (string.IsNullOrEmpty(mark)) { Debug.LogError(string.Format("File : {0} mark: {1} is null", mFilePath, mark)); return; } if (mContent.Contains(text)) { mContent.Replace(text, string.Empty); } int beginIndex = mContent.IndexOf(mark); if (beginIndex == -1) { Debug.LogError(string.Format("File : {0} not found append mark: {1}", mFilePath, mark)); return; } int endIndex = mContent.LastIndexOf("\n", beginIndex + mark.Length); mContent = mContent.Substring(0, endIndex) + "\n" + text + "\n" + mContent.Substring(endIndex); }
public static void Process(string pathToBuildProject) { Debug.Log("iOSPostProcess: Starting to perform post build tasks for iOS platform."); #if UNITY_IOS if (pathToBuildProject == null) { return; } var settings = ProjectXcodeConfigure.Current.Settings; if (settings == null || settings.Count == 0) { return; } var setting = settings.Find(s => s.group == "default"); if (setting == null) { return; } SetInfoPlist(pathToBuildProject, setting); ModifyPBXProject(pathToBuildProject, setting, ""); ModifyXcodeCodes(pathToBuildProject, setting); #endif }
//[UnityEditor.MenuItem("Tools/导出自解压安装包exe")] //public static void Test() //{ // string path = EditorUtility.OpenFolderPanel("请选择需要压缩的目录", "../ProjectBuilder/Output/PC", ""); // if (string.IsNullOrEmpty(path)) return; // if (!File.Exists(path + "/ylqt-Setup.exe")) // { // EditorUtility.DisplayDialog("", "不合法的目录", "确认"); // return; // } // GenerateWinExe(path + "/ylqt-Setup.exe"); //} public static void GenerateWinExe(string pathToBuiltProject) { Debug.Log("BuildProjectPath: " + pathToBuiltProject); string zipRootDir = Path.GetDirectoryName(pathToBuiltProject) + "/"; string path = Path.GetDirectoryName(pathToBuiltProject); int index = path.LastIndexOf("/"); string setupName = path.Substring(index, path.Length - index); //string setupExeName = Path.GetFileName(pathToBuiltProject); string targetExePath = zipRootDir + setupName + ".exe"; if (File.Exists(targetExePath)) { File.Delete(targetExePath); } //复制icon string icoFilePath = zipRootDir + "icon.ico"; string bmpFilePath = zipRootDir + "icon.bmp"; string sfxConfigPath = zipRootDir + "sfxConfig.txt"; string uninstallPath = zipRootDir + "uninstall.exe"; File.Copy("Assets/Res/Logo/PC/icon.ico", icoFilePath, true); File.Copy("Assets/Res/Logo/PC/icon.bmp", bmpFilePath, true); File.Copy("Assets/Res/Logo/PC/sfxConfig.txt", sfxConfigPath, true); File.Copy("Assets/Res/Logo/PC/uninstall.exe", uninstallPath, true); //获取winrar路径 var regKeyPath = @"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\WinRAR.exe"; string winrarPath = null; try {//windows var regKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(regKeyPath); winrarPath = regKey.GetValue("").ToString(); regKey.Close(); } catch (Exception) {//mac os winrarPath = "/usr/local/bin/rar"; File.Copy("Assets/Res/Logo/PC/sfxConfigMac.txt", sfxConfigPath, true); } Debug.Log("WinRAR.exe Path=" + winrarPath); // StringBuilder sfxConfig = new StringBuilder(); // sfxConfig.AppendLine("Title=妖恋奇谭安装程序"); //安装标题 // sfxConfig.AppendLine("Text=妖恋奇谭说明"); //安装说明 // sfxConfig.AppendLine("Path=C:\\Program Files\\ylqt\\"); //安装路径 // sfxConfig.AppendLine("Shortcut=D," + setupExeName + ",,,"+"妖恋奇谭,"+ "icon.ico"); //桌面快捷方式 // sfxConfig.AppendLine("Overwrite=1"); //覆盖所有文件 // sfxConfig.AppendLine("Update=U"); //更新新的或不存在的文件 // sfxConfig.AppendLine( //@"License=最终用户许可协议书 //{ //所有版权于 妖恋奇谭 均属于作者所专有。 //此程序是共享软件,任何人在测试期限内均可以使用此软件。 //在测试期限过后,您“必须”注册。 //}" // ); //许可 //File.WriteAllText(sfxConfigPath, sfxConfig.ToString()); string argument = ""; argument += "a -r -sfx "; //压缩,递归,自解压 argument += "-iimg" + "icon.bmp "; //解压图标 argument += "-iicon" + "icon.ico "; //解压图标 argument += "-zsfxConfig.txt "; //注释 argument += targetExePath + " * "; //指定目录 Debug.Log("argument=" + argument); try {//运行进程 var p = new System.Diagnostics.Process(); p.StartInfo.FileName = winrarPath; p.StartInfo.WorkingDirectory = zipRootDir; p.StartInfo.Arguments = argument; p.StartInfo.ErrorDialog = false; p.StartInfo.UseShellExecute = false; p.StartInfo.CreateNoWindow = false; p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;//与CreateNoWindow联合使用可以隐藏进程运行的窗体 p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardError = true; p.EnableRaisingEvents = true; // 启用Exited事件 //p.Exited += p_Exited; p.Start(); p.WaitForExit(); if (p.ExitCode == 0)//正常退出 { //TODO记录日志 Debug.Log("执行完毕!"); } else { Debug.LogError("error exitcode " + p.ExitCode); } } catch (Exception ex) { throw new Exception("系统错误:", ex); } }
public void SetPermission(string key, string val) { root.SetString(key, val); Debug.Log(string.Format("Set Permission : {0}, Value : {1}", key, val)); }
public void AddBooleanKey(string key, bool val) { root.SetBoolean(key, val); Debug.Log(string.Format("Set Boolean -> Key : {0}, Value : {1}", key, val)); }
private static void onPostprocessBuild(BuildTarget target, string pathToBuildProject) { Debug.Log("Starting to perform Postprocess build tasks for {0} platform.", target); PlayerSettingsSnapshot.ApplySnapshot(); }
public static void SetSplashScreen() { if (GlobalToolConfigure.Current == null || GlobalToolConfigure.Current.SDK == null) { Debug.LogError("GlobalToolConfigure not found, Cannot set default icon"); return; } if (string.IsNullOrEmpty(GlobalToolConfigure.Current.SDK.DefaultIconFilter) || string.IsNullOrEmpty(GlobalToolConfigure.Current.SDK.DefaultIconFilterSearchPath)) { Debug.LogError("GlobalToolConfigure -> SplashScreenFilter、SplashScreenFilterSearchPath is error, Cannot set default icon"); return; } RestoreSplashData(); Debug.Log("Starting set splash screen"); string filter = GlobalToolConfigure.Current.SDK.SplashScreenFilter; string filterSearchPath = BuildPipelineAsset.GetChannelFilterSearchPath(GlobalToolConfigure.Current.SDK.SplashScreenFilterSearchPath); var folders = new List <string>() { filterSearchPath }; string[] searchInFolders = folders.ToArray(); string[] assets = AssetDatabase.FindAssets(filter, searchInFolders); if (assets == null || assets.Length == 0) { Debug.LogError(string.Format("Dir: {0} 下未找到匹配的资源, SplashScreen设置失败", filterSearchPath)); return; } PlayerSettingsResolver.SetSplashScreen(backgroundColor: Color.white, show: true, showUnityLogo: false, drawMode: PlayerSettings.SplashScreen.DrawMode.AllSequential); List <Texture2D> mSplashs = new List <Texture2D>(); mSplashs.Clear(); for (int i = 0; assets != null && i < assets.Length; i++) { string assetPath = AssetDatabase.GUIDToAssetPath(assets[i]); if (assetPath == null) { continue; } Texture2D asset = AssetDatabase.LoadAssetAtPath <Texture2D>(assetPath); if (asset == null) { continue; } mSplashs.Add(asset); } BuildTarget buildTarget = EditorUserBuildSettings.activeBuildTarget; switch (buildTarget) { case BuildTarget.iOS: PlayerSettingsResolver.iOS.SetiPhoneLaunchScreenType(iOSLaunchScreenType.ImageAndBackgroundRelative); QuickEditorUtils.SetSplashScreen("iOSLaunchScreenPortrait", mSplashs[0]); QuickEditorUtils.SetSplashScreen("iOSLaunchScreenLandscape", mSplashs[0]); break; case BuildTarget.Android: QuickEditorUtils.SetSplashScreen("androidSplashScreen", mSplashs[0]); break; default: break; } //PlayerSettings.SplashScreen.background = mSplashs[0]; AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); Debug.Log("Set splash screen succeeded"); }
public static void SetDefaultIcon() { if (GlobalToolConfigure.Current == null || GlobalToolConfigure.Current.SDK == null) { Debug.LogError("GlobalToolConfigure not found, Cannot set default icon"); return; } if (string.IsNullOrEmpty(GlobalToolConfigure.Current.SDK.DefaultIconFilter) || string.IsNullOrEmpty(GlobalToolConfigure.Current.SDK.DefaultIconFilterSearchPath)) { Debug.LogError("GlobalToolConfigure -> DefaultIconFilter、DefaultIconFilterSearchPath is error, Cannot set default icon"); return; } Debug.Log("Starting set default icon"); string filter = GlobalToolConfigure.Current.SDK.DefaultIconFilter; string filterSearchPath = BuildPipelineAsset.GetChannelFilterSearchPath(GlobalToolConfigure.Current.SDK.DefaultIconFilterSearchPath); var folders = new List <string>() { filterSearchPath }; string[] searchInFolders = folders.ToArray(); string[] assets = AssetDatabase.FindAssets(filter, searchInFolders); if (assets == null || assets.Length == 0) { Debug.LogError(string.Format("Dir: {0} 下未找到匹配的资源, Icon设置失败", filterSearchPath)); return; } List <Texture2D> mTextures = new List <Texture2D>(); mTextures.Clear(); for (int i = 0; assets != null && i < assets.Length; i++) { string assetPath = AssetDatabase.GUIDToAssetPath(assets[i]); if (assetPath == null) { continue; } Texture2D asset = AssetDatabase.LoadAssetAtPath <Texture2D>(assetPath); if (asset == null) { continue; } mTextures.Add(asset); } BuildTarget buildTarget = EditorUserBuildSettings.activeBuildTarget; BuildTargetGroup buildTargetGroup = BuildPipelineCommonTools.BuildUtils.GetBuildTargetGroup(buildTarget); int[] iconSize = PlayerSettings.GetIconSizesForTargetGroup(buildTargetGroup); Texture2D[] textureArray = new Texture2D[iconSize.Length]; for (int i = 0; i < textureArray.Length; i++) { textureArray[i] = mTextures[0]; } PlayerSettings.SetIconsForTargetGroup(buildTargetGroup, textureArray); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); Debug.Log("Set default icon succeeded"); //MethodInfo getIconFormPlatform = typeof(PlayerSettings).GetMethod("GetIconsForPlatform", BindingFlags.NonPublic | BindingFlags.Static); //MethodInfo getIconSizesForPlatform = typeof(PlayerSettings).GetMethod("GetIconSizesForPlatform", BindingFlags.NonPublic | BindingFlags.Static); //MethodInfo setIconsForPlatform = typeof(PlayerSettings).GetMethod("SetIconsForPlatform", BindingFlags.NonPublic | BindingFlags.Static); //Texture2D[] textureArray = (Texture2D[])getIconFormPlatform.Invoke(null, new object[] { string.Empty }); //var iconSizesForPlatform = (int[])getIconSizesForPlatform.Invoke(null, new object[] { string.Empty }); //if (textureArray.Length != iconSizesForPlatform.Length) //{ // textureArray = new Texture2D[iconSizesForPlatform.Length]; // setIconsForPlatform.Invoke(null, new object[] { string.Empty, textureArray }); //} //textureArray[0] = mTextures[0]; //setIconsForPlatform.Invoke(null, new object[] { string.Empty, textureArray }); //AssetDatabase.SaveAssets(); }