PrefabDatabase.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. namespace ARLocation
  4. {
  5. [CreateAssetMenu(fileName = "PrefabDb", menuName = "AR+GPS/PrefabDatabase")]
  6. public class PrefabDatabase : ScriptableObject
  7. {
  8. [System.Serializable]
  9. public class PrefabDatabaseEntry
  10. {
  11. /// <summary>
  12. /// The `MeshId` associated with the prefab. Should match a `MeshId` from the data created
  13. /// the Web Map Editor (https://editor.unity-ar-gps-location.com).
  14. /// </summary>
  15. public string MeshId;
  16. /// <summary>
  17. /// The prefab you want to associate with the `MeshId`.
  18. /// </summary>
  19. public GameObject Prefab;
  20. }
  21. public List<PrefabDatabaseEntry> Entries;
  22. public GameObject GetEntryById(string Id)
  23. {
  24. GameObject result = null;
  25. foreach (var entry in Entries)
  26. {
  27. if (entry.MeshId == Id)
  28. {
  29. result = entry.Prefab;
  30. break;
  31. }
  32. }
  33. return result;
  34. }
  35. }
  36. }