[TASK] Initial commit with basic product setup
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Mapbox.Unity.Map;
|
||||
|
||||
public class SetCameraHeight : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
AbstractMap _map;
|
||||
|
||||
[SerializeField]
|
||||
Camera _referenceCamera;
|
||||
[SerializeField]
|
||||
float _cameraOffset = 100f;
|
||||
// Use this for initialization
|
||||
void Start()
|
||||
{
|
||||
if (_map == null)
|
||||
{
|
||||
_map = FindObjectOfType<AbstractMap>();
|
||||
}
|
||||
if (_referenceCamera == null)
|
||||
{
|
||||
_referenceCamera = FindObjectOfType<Camera>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
var position = _referenceCamera.transform.position;
|
||||
position.y = _map.QueryElevationInMetersAt(_map.CenterLatitudeLongitude) + _cameraOffset;
|
||||
_referenceCamera.transform.position = position;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4068899586d2d4e21bccf5a6b475a3bb
|
||||
timeCreated: 1521502809
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,55 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dcf32ea2cc0514b569329f6b6b68f9b4
|
||||
timeCreated: 1512163458
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user