BuildConfig.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. #if UNITY_EDITOR
  2. using UnityEditor;
  3. #endif
  4. using UnityEngine;
  5. namespace XRTool.Util
  6. {
  7. /// <summary>
  8. /// public Version(int major, int minor, int build, int revision);
  9. /// </summary>
  10. public enum BuildVersion
  11. {
  12. /// <summary>
  13. /// 主要
  14. /// </summary>
  15. Major = 0,
  16. /// <summary>
  17. /// 次要
  18. /// </summary>
  19. Minor = 1,
  20. /// <summary>
  21. /// 构建版本
  22. /// </summary>
  23. Build = 2
  24. ///// <summary>
  25. ///// 补丁版本,修订
  26. ///// </summary>
  27. //revision = 3,
  28. }
  29. /// <summary>
  30. /// 发布模式
  31. /// 主要根据此模式,来做对应的处理,例如debug模式下,会输出全部日志
  32. /// 测试模式下,会输出error和异常。测试模式下可以调出相关的指令,但是输出更多的设置内容
  33. /// release是正式发布版本,不会输出日志。同时提升系统性能
  34. /// debug,test,release
  35. /// </summary>
  36. public enum BuildType
  37. {
  38. /// <summary>
  39. /// 日志模式,可以记录用户日志
  40. /// </summary>
  41. Debug = 0,
  42. /// <summary>
  43. /// 测试版本,程序自测版本,拥有更多的操控权限
  44. /// </summary>
  45. Test = 1,
  46. /// <summary>
  47. /// 商用版本
  48. /// </summary>
  49. Release = 2
  50. }
  51. /// <summary>
  52. /// 资源的读取方式Editor LocalEditor
  53. /// </summary>
  54. public enum AssetsType
  55. {
  56. /// <summary>
  57. /// Resource加载,仅支持Resource路径下的资源加载
  58. /// 其他模式为了后续支持AssetBundle资源加载
  59. /// </summary>
  60. Resource = -2,
  61. /// <summary>
  62. /// 编辑器模式下,读取编辑器Asset下资源
  63. /// </summary>
  64. Editor = -1,
  65. /// <summary>
  66. /// 编辑器模式下读取指定路径的打包后的资源
  67. /// </summary>
  68. LocalEditor = 0,
  69. /// <summary>
  70. /// 真机运行下读取游戏路径下的资源
  71. /// </summary>
  72. LocalPhone = 1,
  73. /// <summary>
  74. /// 真机运行下读取指定路径下的资源
  75. /// </summary>
  76. App = 2,
  77. /// <summary>
  78. /// 读取StreamingAsset路径下资源
  79. /// </summary>
  80. Stream = 3
  81. }
  82. /// <summary>
  83. /// 编译的平台
  84. /// 在打包的时候要选择对应的平台
  85. /// </summary>
  86. public enum BuildPlatform
  87. {
  88. /// <summary>
  89. /// PC版本
  90. /// </summary>
  91. StandaloneWindows = 0,
  92. /// <summary>
  93. /// IOS版本
  94. /// </summary>
  95. iOS = 1,
  96. /// <summary>
  97. /// 安卓版本
  98. /// </summary>
  99. Android = 2
  100. }
  101. /// <summary>
  102. /// 播放模式
  103. /// </summary>
  104. public enum PlayType
  105. {
  106. /// <summary>
  107. /// 电脑模式,PC端运行
  108. /// </summary>
  109. PC = 0,
  110. /// <summary>
  111. /// VR模式,VR头盔
  112. /// </summary>
  113. VRGlass = 1,
  114. /// <summary>
  115. /// AR模式,AR眼睛
  116. /// </summary>
  117. ARGlass = 2,
  118. /// <summary>
  119. /// 移动手机模式,触屏操作
  120. /// </summary>
  121. Mobile = 3
  122. }
  123. public class BuildConfig : ScriptableObject
  124. {
  125. public static BuildConfig Instance;
  126. /// <summary>
  127. /// 发布模式,debug release
  128. /// </summary>
  129. [Tooltip("发布模式")]
  130. public BuildType buildType;
  131. /// <summary>
  132. /// 资源访问方式LocalEditor APP
  133. /// </summary>
  134. [Tooltip("资源访问方式")]
  135. public AssetsType assetsType;
  136. /// <summary>
  137. /// 发布的平台 BuildTarget IOS Android
  138. /// </summary>
  139. #if UNITY_EDITOR
  140. [Tooltip("发布的平台")]
  141. public BuildTarget buildTarget;
  142. #endif
  143. /// <summary>
  144. /// 运行的模式Normal AR
  145. /// </summary>
  146. [Tooltip("运行的模式")]
  147. public PlayType playType;
  148. [Tooltip("APP发布时间")]
  149. public string buildTime;
  150. [Tooltip("APP版本号")]
  151. public string appVersion;
  152. public ServerConfig[] serverList;
  153. public string otherSymbol = "TRILIB_USE_ZIP";
  154. /// <summary>
  155. /// 版本类型,修订版,补丁版
  156. /// </summary>
  157. [Tooltip("版本类型")]
  158. public BuildVersion buildVersion = BuildVersion.Build;
  159. public string languagePath = "Language";
  160. public string artInfoPath="ArtInfo";
  161. public string prefix = "T";
  162. public bool useHand = false;
  163. public string loginUrl;
  164. public string lobbyUrl;
  165. public string roomUrl;
  166. public string rtcUrl;
  167. #if UNITY_EDITOR
  168. public BuildTargetGroup buildTargetGroup = BuildTargetGroup.Standalone;
  169. [MenuItem("Assets/Create/BuildConfig", false, 0)]
  170. static void CreateDynamicConf()
  171. {
  172. Object obj = Selection.activeObject;
  173. if (obj)
  174. {
  175. string path = AssetDatabase.GetAssetPath(obj);
  176. BuildConfig bullet = CreateInstance<BuildConfig>();
  177. if (bullet)
  178. {
  179. string confName =UnityUtil. TryGetName<BuildConfig>(path);
  180. AssetDatabase.CreateAsset(bullet, confName);
  181. Instance = bullet;
  182. }
  183. else
  184. {
  185. Debug.Log(typeof(BuildConfig) + " is null");
  186. }
  187. }
  188. }
  189. #endif
  190. }
  191. }