Skip to content
Snippets Groups Projects
Commit b85fe4c4 authored by LE-CUDENEC JOFFREY's avatar LE-CUDENEC JOFFREY
Browse files

Merge branch 'lecudenec-main-patch-69904' into 'main'

Delete SpawnOnMap.cs

See merge request !54
parents 1eba3ff1 d60c1ba7
1 merge request!54Delete SpawnOnMap.cs
namespace Mapbox.Examples
{
using UnityEngine;
using Mapbox.Utils;
using Mapbox.Unity.Map;
using Mapbox.Unity.MeshGeneration.Factories;
using Mapbox.Unity.Utilities;
using System.Collections.Generic;
public class SpawnOnMap : MonoBehaviour
{
[SerializeField]
AbstractMap _map;
[SerializeField]
[Geocode]
string[] _locationStrings;
Vector2d[] _locations;
[SerializeField]
float _spawnScale = 100f;
[SerializeField]
GameObject _markerPrefab;
List<GameObject> _spawnedObjects;
void Start()
{
_locations = new Vector2d[_locationStrings.Length];
_spawnedObjects = new List<GameObject>();
for (int i = 0; i < _locationStrings.Length; i++)
{
var locationString = _locationStrings[i];
_locations[i] = Conversions.StringToLatLon(locationString);
var instance = Instantiate(_markerPrefab);
instance.transform.localPosition = _map.GeoToWorldPosition(_locations[i], true);
instance.transform.localScale = new Vector3(_spawnScale, _spawnScale, _spawnScale);
_spawnedObjects.Add(instance);
}
}
private void Update()
{
int count = _spawnedObjects.Count;
for (int i = 0; i < count; i++)
{
var spawnedObject = _spawnedObjects[i];
var location = _locations[i];
spawnedObject.transform.localPosition = _map.GeoToWorldPosition(location, true);
spawnedObject.transform.localScale = new Vector3(_spawnScale, _spawnScale, _spawnScale);
}
}
}
}
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment