AR + GPS Location  3.0.0
All Classes Namespaces Functions Variables Properties Events Pages
PlaceAtLocations.cs
1 using System;
2 using System.Collections.Generic;
3 using UnityEngine;
4 using UnityEngine.Serialization;
5 // ReSharper disable CollectionNeverQueried.Local
6 // ReSharper disable MemberCanBePrivate.Global
7 
8 namespace ARLocation
9 {
10 
16  [AddComponentMenu("AR+GPS/Place At Locations")]
17  [HelpURL("https://http://docs.unity-ar-gps-location.com/guide/#placeatlocations")]
18  public class PlaceAtLocations : MonoBehaviour
19  {
20  [Serializable]
21  public class Entry
22  {
23  public LocationData ObjectLocation;
24  public OverrideAltitudeData OverrideAltitude = new OverrideAltitudeData();
25  }
26 
27  [Tooltip("The locations where the objects will be instantiated.")]
28  public List<PlaceAtLocation.LocationSettingsData> Locations;
29 
30  public PlaceAtLocation.PlaceAtOptions PlacementOptions;
31 
35  [FormerlySerializedAs("prefab")] [Tooltip("The game object that will be instantiated.")]
36  public GameObject Prefab;
37 
38  [Space(4.0f)]
39 
40  [Header("Debug")]
41  [Tooltip("When debug mode is enabled, this component will print relevant messages to the console. Filter by 'PlateAtLocations' in the log output to see the messages.")]
42  public bool DebugMode;
43 
44  [Space(4.0f)]
45 
46  private readonly List<Location> locations = new List<Location>();
47  private readonly List<GameObject> instances = new List<GameObject>();
48 
49  public List<GameObject> Instances => instances;
50 
51  private void Start()
52  {
53  foreach (var entry in Locations)
54  {
55  var newLoc = entry.GetLocation();
56 
57  AddLocation(newLoc);
58  }
59  }
60 
61  public void AddLocation(Location location)
62  {
63  var instance = PlaceAtLocation.CreatePlacedInstance(Prefab, location, PlacementOptions, DebugMode);
64 
65  instance.name = $"{gameObject.name} - {locations.Count}";
66 
67  locations.Add(location);
68  instances.Add(instance);
69  }
70  }
71 }
ARLocation.LocationData
Data used to construct a spline passing trough a set of geographical locations.
Definition: LocationData.cs:12
ARLocation.PlaceAtLocations.Prefab
GameObject Prefab
The game object that will be instantiated.
Definition: PlaceAtLocations.cs:36
ARLocation.PlaceAtLocations.Entry
Definition: PlaceAtLocations.cs:22
ARLocation.PlaceAtLocation.PlaceAtOptions
Definition: PlaceAtLocation.cs:62
ARLocation.OverrideAltitudeData
Definition: PlaceAtLocation.cs:12
ARLocation.PlaceAtLocation
Apply to a GameObject to place it at a specified geographic location.
Definition: PlaceAtLocation.cs:54
ARLocation.PlaceAtLocations
This class instantiates a prefab at the given GPS locations. Must be in the ARLocationRoot GameObject...
Definition: PlaceAtLocations.cs:19
ARLocation
Definition: ARLocationConfigInspector.cs:7
ARLocation.PlaceAtLocation.LocationSettingsData
Definition: PlaceAtLocation.cs:89