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.

47 lines
1.6 KiB

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