SensorHandler.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using CSVReader;
  5. public class SensorHandler : AbstractSensorHandler
  6. {
  7. // Start is called before the first frame update
  8. ///<summary>
  9. /// CSV Filename to read from
  10. ///</summary>
  11. [SerializeField] string filename;
  12. ///<summary>
  13. /// Sensor Prefab to use
  14. ///</summary>
  15. [SerializeField] GameObject SensorPrefab;
  16. ///<summary>
  17. /// SensorCSV Reader
  18. ///</summary>
  19. SensorCSVReader SensorCSV;
  20. void Start()
  21. {
  22. SensorList = new Dictionary<int, GameObject>();
  23. //Create new SensorCSV Reader
  24. SensorCSV = new SensorCSVReader(filename);
  25. //Read Sensors
  26. SensorObject[] sensors = SensorCSV.ReadFile();
  27. //create sensor objects
  28. foreach (SensorObject sensor in sensors)
  29. {
  30. GameObject sensorObject = Instantiate(SensorPrefab);
  31. sensorObject.transform.position = sensor.Pos;
  32. sensorObject.transform.eulerAngles = sensor.Rot;
  33. sensorObject.name = "Sensor" + sensor.ID;
  34. SensorList.Add(sensor.ID,sensorObject);
  35. }
  36. }
  37. // Update is called once per frame
  38. void Update()
  39. {
  40. }
  41. }