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