当前位置:   article > 正文

Unity3d Android IOS 自动设置 签名和输出 路径_unity iostargetosversionstring

unity iostargetosversionstring

大家先熟悉 下这个 [InitializeOnLoad] 。 这个标签 是 Unity3D刚打开 或者 运行时候的回调;那我们就给予它开始代码


  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEditor;
  5. using System.IO;
  6. using BoTing.Updater;
  7. [InitializeOnLoad]
  8. public static class ProjectAutoSetting
  9. {
  10. static ProjectAutoSetting()
  11. {
  12. //EditorUserBuildSettings.activeBuildTargetChanged = delegate () {
  13. // if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android)
  14. // {
  15. // Debug.Log("DoSomeThings");
  16. // }
  17. //};
  18. //EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.Android);
  19. //EditorUserBuildSettings.activeBuildTargetChanged += OnAutoSetting;
  20. OnAutoSetting();
  21. }
  22. static void OnAutoSetting()
  23. {
  24. if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android)
  25. {
  26. OnAndroid();
  27. }
  28. else if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.iOS)
  29. {
  30. OnIOS();
  31. }
  32. }
  33. static void OnAndroid()
  34. {
  35. //Debug.Log("OnAndroid");
  36. DirectoryInfo dir = Directory.GetParent(Application.dataPath).Parent;
  37. string path = dir.ToString() + @"\KeyStore\user_Phoenix.keystore";//自己的路径
  38. //Debug.Log(path);
  39. if (File.Exists(path))
  40. {
  41. PlayerSettings.Android.keystoreName = path;
  42. PlayerSettings.Android.keyaliasName = "phoenix";
  43. PlayerSettings.keystorePass = "youxi9123";
  44. PlayerSettings.keyaliasPass = "phoenix9123";
  45. PlayerSettings.applicationIdentifier = "com.fenghuang.yule";
  46. PlayerSettings.companyName = "912娱乐";
  47. PlayerSettings.productName = "凤凰竞技娱乐";
  48. PlayerSettings.bundleVersion = UpdaterConfig.AppVersion;//这里这几根据项目设置 我这里有全局的
  49. PlayerSettings.Android.bundleVersionCode = int.Parse(System.DateTime.Now.ToString("yyMMddHHmm"));
  50. }
  51. string outPath = Directory.GetParent(Application.dataPath).Parent.ToString() + "/" + PlayerSettings.productName + "_" + System.DateTime.Now.ToString("yyyyMMddHHmm");
  52. EditorUserBuildSettings.SetBuildLocation(BuildTarget.Android, outPath);
  53. }
  54. static void OnIOS()
  55. {
  56. //Debug.Log("OnIOS");
  57. PlayerSettings.applicationIdentifier = "com.fenghuang.yule";
  58. PlayerSettings.bundleVersion = "1.9.115";
  59. PlayerSettings.iOS.applicationDisplayName = "凤凰竞技娱乐";
  60. PlayerSettings.iOS.targetOSVersionString = "8";
  61. PlayerSettings.iOS.buildNumber = System.DateTime.Now.ToString("yyyyMMddHHmm");
  62. PlayerSettings.iOS.sdkVersion = iOSSdkVersion.DeviceSDK;
  63. }
  64. }


声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/112064?site
推荐阅读
相关标签
  

闽ICP备14008679号