DataLocationsInfo.cs 872 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. [ExecuteInEditMode]
  5. [CreateAssetMenu(fileName = "LocationsInfo", menuName = "EditorDatas/LocationsInfo", order = 1)]
  6. public class DataLocationsInfo : ScriptableObject
  7. {
  8. [Serializable]
  9. public struct City
  10. {
  11. public string name;
  12. public List<string> places;
  13. }
  14. [Serializable]
  15. public struct State
  16. {
  17. public string name;
  18. public List<City> cities;
  19. }
  20. public List<State> states = new List<State>();
  21. public void GetLocationData(string locId, out string locCity, out string locState)
  22. {
  23. locCity = "";
  24. locState = "";
  25. foreach(State state in states)
  26. {
  27. foreach(City city in state.cities)
  28. {
  29. foreach(string place in city.places)
  30. {
  31. if(place.ToUpper() == locId.ToUpper())
  32. {
  33. locCity = city.name;
  34. locState = state.name;
  35. return;
  36. }
  37. }
  38. }
  39. }
  40. }
  41. }