12345678910111213141516171819202122232425262728293031323334 |
- using Newtonsoft.Json;
- using System;
- using System.IO;
- using UnityEngine;
- namespace Assets.StreetLight
- {
- public sealed class Configuration
- {
- private string homographyFilePath;
- /// <summary>
- /// The file path to the csv file containing the homography for mapping world coodrinates to Unity coordinates.
- /// </summary>
- [JsonRequired]
- public string HomographyFilePath
- {
- get => homographyFilePath;
- set
- {
- if (!File.Exists(value))
- {
- throw new InvalidOperationException($"File \"{value}\" does not exist.");
- }
- homographyFilePath = value;
- }
- }
- private static readonly Lazy<Configuration> lazy = new(() => JsonConvert.DeserializeObject<Configuration>(File.ReadAllText(Path.Combine(Application.streamingAssetsPath, "Configuration.json"))));
- public static Configuration Instance => lazy.Value;
- private Configuration() { }
- }
- }
|