OVRPlatformToolSettings.cs 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace Assets.Oculus.VR.Editor
  5. {
  6. #if UNITY_EDITOR
  7. [UnityEditor.InitializeOnLoad]
  8. #endif
  9. public sealed class OVRPlatformToolSettings : ScriptableObject
  10. {
  11. private const string DEFAULT_RELEASE_CHANNEL = "Alpha";
  12. public enum GamepadType
  13. {
  14. OFF,
  15. TWINSTICK,
  16. RIGHT_D_PAD,
  17. LEFT_D_PAD,
  18. };
  19. public static string AppID
  20. {
  21. get
  22. {
  23. return Instance.targetPlatform < OVRPlatformTool.TargetPlatform.None ? Instance.appIDs[(int)Instance.targetPlatform] : "";
  24. }
  25. set
  26. {
  27. if (Instance.targetPlatform < OVRPlatformTool.TargetPlatform.None)
  28. {
  29. Instance.appIDs[(int)Instance.targetPlatform] = value;
  30. }
  31. }
  32. }
  33. public static string ReleaseNote
  34. {
  35. get
  36. {
  37. return Instance.targetPlatform < OVRPlatformTool.TargetPlatform.None ? Instance.releaseNotes[(int)Instance.targetPlatform] : "";
  38. }
  39. set
  40. {
  41. if (Instance.targetPlatform < OVRPlatformTool.TargetPlatform.None)
  42. {
  43. Instance.releaseNotes[(int)Instance.targetPlatform] = value;
  44. }
  45. }
  46. }
  47. public static string ReleaseChannel
  48. {
  49. get
  50. {
  51. return Instance.targetPlatform < OVRPlatformTool.TargetPlatform.None ? Instance.releaseChannels[(int)Instance.targetPlatform] : "";
  52. }
  53. set
  54. {
  55. if (Instance.targetPlatform < OVRPlatformTool.TargetPlatform.None)
  56. {
  57. Instance.releaseChannels[(int)Instance.targetPlatform] = value;
  58. }
  59. }
  60. }
  61. public static string ApkBuildPath
  62. {
  63. get
  64. {
  65. return Instance.targetPlatform < OVRPlatformTool.TargetPlatform.None ? Instance.apkBuildPaths[(int)Instance.targetPlatform] : "";
  66. }
  67. set
  68. {
  69. if (Instance.targetPlatform < OVRPlatformTool.TargetPlatform.None)
  70. {
  71. Instance.apkBuildPaths[(int)Instance.targetPlatform] = value;
  72. }
  73. }
  74. }
  75. public static string ObbFilePath
  76. {
  77. get
  78. {
  79. return Instance.targetPlatform < OVRPlatformTool.TargetPlatform.None ? Instance.obbFilePaths[(int)Instance.targetPlatform] : "";
  80. }
  81. set
  82. {
  83. if (Instance.targetPlatform < OVRPlatformTool.TargetPlatform.None)
  84. {
  85. Instance.obbFilePaths[(int)Instance.targetPlatform] = value;
  86. }
  87. }
  88. }
  89. public static string AssetsDirectory
  90. {
  91. get
  92. {
  93. return Instance.targetPlatform < OVRPlatformTool.TargetPlatform.None ? Instance.assetsDirectorys[(int)Instance.targetPlatform] : "";
  94. }
  95. set
  96. {
  97. if (Instance.targetPlatform < OVRPlatformTool.TargetPlatform.None)
  98. {
  99. Instance.assetsDirectorys[(int)Instance.targetPlatform] = value;
  100. }
  101. }
  102. }
  103. public static string RiftBuildDirectory
  104. {
  105. get { return Instance.riftBuildDiretory; }
  106. set { Instance.riftBuildDiretory = value; }
  107. }
  108. public static string RiftBuildVersion
  109. {
  110. get { return Instance.riftBuildVersion; }
  111. set { Instance.riftBuildVersion = value; }
  112. }
  113. public static string RiftLaunchFile
  114. {
  115. get { return Instance.riftLaunchFile; }
  116. set { Instance.riftLaunchFile = value; }
  117. }
  118. public static string RiftLaunchParams
  119. {
  120. get { return Instance.riftLaunchParams; }
  121. set { Instance.riftLaunchParams = value; }
  122. }
  123. public static string Rift2DLaunchFile
  124. {
  125. get { return Instance.rift2DLaunchFile; }
  126. set { Instance.rift2DLaunchFile = value; }
  127. }
  128. public static string Rift2DLaunchParams
  129. {
  130. get { return Instance.rift2DLaunchParams; }
  131. set { Instance.rift2DLaunchParams = value; }
  132. }
  133. public static bool RiftFirewallException
  134. {
  135. get { return Instance.riftFirewallException; }
  136. set { Instance.riftFirewallException = value; }
  137. }
  138. public static GamepadType RiftGamepadEmulation
  139. {
  140. get { return Instance.riftGamepadEmulation; }
  141. set { Instance.riftGamepadEmulation = value; }
  142. }
  143. public static List<RedistPackage> RiftRedistPackages
  144. {
  145. get { return Instance.riftRedistPackages; }
  146. set { Instance.riftRedistPackages = value; }
  147. }
  148. public static string LanguagePackDirectory
  149. {
  150. get { return Instance.languagePackDirectory; }
  151. set { Instance.languagePackDirectory = value; }
  152. }
  153. public static List<AssetConfig> AssetConfigs
  154. {
  155. get
  156. {
  157. return Instance.targetPlatform < OVRPlatformTool.TargetPlatform.None ? Instance.assetConfigs[(int)Instance.targetPlatform].configList : new List<AssetConfig>();
  158. }
  159. set
  160. {
  161. if (Instance.targetPlatform < OVRPlatformTool.TargetPlatform.None)
  162. {
  163. Instance.assetConfigs[(int)Instance.targetPlatform].configList = value;
  164. }
  165. }
  166. }
  167. public static OVRPlatformTool.TargetPlatform TargetPlatform
  168. {
  169. get { return Instance.targetPlatform; }
  170. set { Instance.targetPlatform = value; }
  171. }
  172. public static bool RunOvrLint
  173. {
  174. get { return Instance.runOvrLint; }
  175. set { Instance.runOvrLint = value; }
  176. }
  177. [SerializeField]
  178. private string[] appIDs = new string[(int)OVRPlatformTool.TargetPlatform.None];
  179. [SerializeField]
  180. private string[] releaseNotes = new string[(int)OVRPlatformTool.TargetPlatform.None];
  181. [SerializeField]
  182. private string[] releaseChannels = new string[(int)OVRPlatformTool.TargetPlatform.None];
  183. [SerializeField]
  184. private string riftBuildDiretory = "";
  185. [SerializeField]
  186. private string riftBuildVersion = "";
  187. [SerializeField]
  188. private string riftLaunchFile = "";
  189. [SerializeField]
  190. private string riftLaunchParams = "";
  191. [SerializeField]
  192. private string rift2DLaunchFile = "";
  193. [SerializeField]
  194. private string rift2DLaunchParams = "";
  195. [SerializeField]
  196. private bool riftFirewallException = false;
  197. [SerializeField]
  198. private GamepadType riftGamepadEmulation = GamepadType.OFF;
  199. [SerializeField]
  200. private List<RedistPackage> riftRedistPackages;
  201. [SerializeField]
  202. private string languagePackDirectory = "";
  203. [SerializeField]
  204. private string[] apkBuildPaths = new string[(int)OVRPlatformTool.TargetPlatform.None];
  205. [SerializeField]
  206. private string[] obbFilePaths = new string[(int)OVRPlatformTool.TargetPlatform.None];
  207. [SerializeField]
  208. private string[] assetsDirectorys = new string[(int)OVRPlatformTool.TargetPlatform.None];
  209. [SerializeField]
  210. private AssetConfigList[] assetConfigs = new AssetConfigList[(int)OVRPlatformTool.TargetPlatform.None];
  211. [SerializeField]
  212. private OVRPlatformTool.TargetPlatform targetPlatform = OVRPlatformTool.TargetPlatform.None;
  213. [SerializeField]
  214. private bool runOvrLint = true;
  215. private static OVRPlatformToolSettings instance;
  216. public static OVRPlatformToolSettings Instance
  217. {
  218. get
  219. {
  220. if (instance == null)
  221. {
  222. instance = Resources.Load<OVRPlatformToolSettings>("OVRPlatformToolSettings");
  223. if (instance == null)
  224. {
  225. instance = ScriptableObject.CreateInstance<OVRPlatformToolSettings>();
  226. string properPath = System.IO.Path.Combine(UnityEngine.Application.dataPath, "Resources");
  227. if (!System.IO.Directory.Exists(properPath))
  228. {
  229. UnityEditor.AssetDatabase.CreateFolder("Assets", "Resources");
  230. }
  231. string fullPath = System.IO.Path.Combine(
  232. System.IO.Path.Combine("Assets", "Resources"),
  233. "OVRPlatformToolSettings.asset"
  234. );
  235. UnityEditor.AssetDatabase.CreateAsset(instance, fullPath);
  236. // Initialize cross platform default values for the new instance of OVRPlatformToolSettings here
  237. if (instance != null)
  238. {
  239. for (int i = 0; i < (int)OVRPlatformTool.TargetPlatform.None; i++)
  240. {
  241. instance.releaseChannels[i] = DEFAULT_RELEASE_CHANNEL;
  242. instance.assetConfigs[i] = new AssetConfigList();
  243. }
  244. instance.riftRedistPackages = new List<RedistPackage>();
  245. }
  246. }
  247. }
  248. return instance;
  249. }
  250. set
  251. {
  252. instance = value;
  253. }
  254. }
  255. }
  256. // Wrapper for asset config list so that it can be serialized properly
  257. [System.Serializable]
  258. public class AssetConfigList
  259. {
  260. public List<AssetConfig> configList;
  261. public AssetConfigList()
  262. {
  263. configList = new List<AssetConfig>();
  264. }
  265. }
  266. [System.Serializable]
  267. public class AssetConfig
  268. {
  269. public enum AssetType
  270. {
  271. DEFAULT,
  272. STORE,
  273. LANGUAGE_PACK,
  274. };
  275. public string name;
  276. public bool required;
  277. public AssetType type;
  278. public string sku;
  279. private bool foldout;
  280. public AssetConfig(string assetName)
  281. {
  282. name = assetName;
  283. }
  284. public bool GetFoldoutState()
  285. {
  286. return foldout;
  287. }
  288. public void SetFoldoutState(bool state)
  289. {
  290. foldout = state;
  291. }
  292. }
  293. [System.Serializable]
  294. public class RedistPackage
  295. {
  296. public bool include = false;
  297. public string name;
  298. public string id;
  299. public RedistPackage(string pkgName, string pkgId)
  300. {
  301. name = pkgName;
  302. id = pkgId;
  303. }
  304. }
  305. }