Configuration.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. using Newtonsoft.Json;
  2. using System;
  3. using System.IO;
  4. using UnityEngine;
  5. namespace Assets.StreetLight
  6. {
  7. public sealed class Configuration
  8. {
  9. private string homographyFilePath;
  10. /// <summary>
  11. /// The file path to the csv file containing the homography for mapping world coodrinates to Unity coordinates.
  12. /// </summary>
  13. [JsonRequired]
  14. public string HomographyFilePath
  15. {
  16. get => homographyFilePath;
  17. set
  18. {
  19. if (!File.Exists(value))
  20. {
  21. throw new InvalidOperationException($"File \"{value}\" does not exist.");
  22. }
  23. homographyFilePath = value;
  24. }
  25. }
  26. private static readonly Lazy<Configuration> lazy = new(() => JsonConvert.DeserializeObject<Configuration>(File.ReadAllText(Path.Combine(Application.streamingAssetsPath, "Configuration.json"))));
  27. public static Configuration Instance => lazy.Value;
  28. private Configuration() { }
  29. }
  30. }