Assignment for RMIT Mixed Reality in 2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.9 KiB

  1. using UnityEngine;
  2. using System.Collections;
  3. #if UNITY_EDITOR
  4. [UnityEditor.InitializeOnLoad]
  5. #endif
  6. public sealed class OvrAvatarSettings : ScriptableObject {
  7. public static string AppID
  8. {
  9. get { return Instance.ovrAppID; }
  10. set { Instance.ovrAppID = value; }
  11. }
  12. public static string MobileAppID
  13. {
  14. get { return Instance.ovrGearAppID; }
  15. set { Instance.ovrGearAppID = value; }
  16. }
  17. private static OvrAvatarSettings instance;
  18. public static OvrAvatarSettings Instance
  19. {
  20. get
  21. {
  22. if (instance == null)
  23. {
  24. instance = Resources.Load<OvrAvatarSettings>("OvrAvatarSettings");
  25. // This can happen if the developer never input their App Id into the Unity Editor
  26. // Use a dummy object with defaults for the getters so we don't have a null pointer exception
  27. if (instance == null)
  28. {
  29. instance = ScriptableObject.CreateInstance<OvrAvatarSettings>();
  30. #if UNITY_EDITOR
  31. // Only in the editor should we save it to disk
  32. string properPath = System.IO.Path.Combine(UnityEngine.Application.dataPath, "Resources");
  33. if (!System.IO.Directory.Exists(properPath))
  34. {
  35. UnityEditor.AssetDatabase.CreateFolder("Assets", "Resources");
  36. }
  37. string fullPath = System.IO.Path.Combine(
  38. System.IO.Path.Combine("Assets", "Resources"),
  39. "OvrAvatarSettings.asset"
  40. );
  41. UnityEditor.AssetDatabase.CreateAsset(instance, fullPath);
  42. #endif
  43. }
  44. }
  45. return instance;
  46. }
  47. set
  48. {
  49. instance = value;
  50. }
  51. }
  52. [SerializeField]
  53. private string ovrAppID = "";
  54. [SerializeField]
  55. private string ovrGearAppID = "";
  56. }