diff --git a/documentation/docs/03-examples.md b/documentation/docs/03-examples.md index bfe692181..bcedf8a40 100644 --- a/documentation/docs/03-examples.md +++ b/documentation/docs/03-examples.md @@ -2,11 +2,11 @@ For each example, associated scripts and resources can be found in the same root directory as the scene itself. -### Playground +## Playground These examples demonstrate how to request specific Mapbox data using our C# library. -#### Forward Geocoder +### Forward Geocoder *ForwardGeocoder.unity* @@ -14,7 +14,7 @@ A forward geocoding request will fetch GeoJSON from a place name query. A new re Visit [our API documentation](https://www.mapbox.com/api-documentation/#geocoding) for more information. -#### Reverse Geocoder +### Reverse Geocoder *ReverseGeocoder.unity* @@ -22,7 +22,7 @@ A reverse geocoding request will fetch GeoJSON from a location query. The locati Visit [our API documentation](https://www.mapbox.com/api-documentation/#geocoding) for more information. -#### Directions +### Directions *Directions.unity* @@ -34,7 +34,7 @@ When the geocode requests have been completed, a directions request is executed. Directions results will be logged to the UI when they are available (in the form of JSON). -#### Raster Tile +### Raster Tile *RasterTile.unity* @@ -44,7 +44,7 @@ See: https://www.mapbox.com/help/define-style/ See: https://www.mapbox.com/api-documentation/#retrieve-raster-tiles-from-styles -#### Vector Tile +### Vector Tile *VectorTile.unity* @@ -54,7 +54,7 @@ In this example, the result is GeoJSON with a feature collection. Visit [our API documentation](https://www.mapbox.com/api-documentation/#retrieve-features-from-vector-tiles) for more information. -### Mesh Generation Basics +## Mesh Generation Basics *MeshGeneration.unity* @@ -68,7 +68,7 @@ See `MapImageFactory.asset` to customize the raster `MapId` you would like to us See `MeshFactory.asset` to see how specific layers are extracted from vector tiles. In this case, we are generating meshes for both `building` and `road`. Therefore, each layer has a `VectorLayerVisualizer` responsible for handling that layer's specific data (such as geometry). -### Mesh Generataion Pois +## Mesh Generataion Pois *PoiGeneration.unity* @@ -76,13 +76,13 @@ With the exception of a `PoiVisualizer ` (`PoiDemoPoiVisualizer`) being added to `PoiDemoPoiVisualizer.asset` allows you to override which prefab to spawn for each `po_label` contained in the vector tile. This prefab should have a component that implements `ILabelVisualizationHelper` attached to it. This exists to inject feature data into (such as label and `Maki` icon). -### Mesh Generation Styles +## Mesh Generation Styles *StylingDemoMeshGeneration.unity* This example demonstrates how to use `TypeFilters` to filter specific features for processing. In this case, we have chosen to exclude `schools` from mesh generation. Additionally, you can use `ModifierStacks` to further customize specific features (to color banks differently, for example). -### Drive +## Drive *Drive.unity* @@ -96,9 +96,9 @@ The ground layer was generated with a `flat` `TerrainFactory` and a `MapImageFac To understand 3D building generation, please see `Mesh Generation Basics`. One particular difference in this example, however, is the use of a `MergedModifierStack` for `DriveBuildingVisualizer.asset`. This `ModifierStack` is responsible for merging buildings during generation. This optimization reduces the number of transforms and draw calls in the scene, vastly improving the final frame rate. -### Slippy Vector Terrain +## Slippy Vector Terrain -*SlippyDemo.Unity* +*SlippyDemo.unity* This example demonstrates one way to create a [slippy map](http://wiki.openstreetmap.org/wiki/Slippy_Map). The `Slippy` component attached to the `MapController` game object is responsible for requesting new tiles as needed, based on the position of the camera relative to the map. This is achieved using `raycasting` and a dictionary of known (requested and fetched) tiles. @@ -106,7 +106,7 @@ Use W, A, S, D keyboard controls to navigate the map at runtime. Please see `Mesh Generation Basics` to understand how features are customized. -### Voxels +## Voxels *VoxelWorld.unity* @@ -124,4 +124,34 @@ This Minecraft-inspired example demonstrates a less traditional way to consume M `Voxel Batch Count`: How many voxels to spawn at once. Keep this number low to prevent locking the main thread during construction. -Please read [the blog post](https://www.mapbox.com/blog/how-to-minecraft-unity/) describing how this was made for more information. \ No newline at end of file +Please read [the blog post](https://www.mapbox.com/blog/how-to-minecraft-unity/) describing how this was made for more information. + +## LocationProvider + +*LocationProvider.unity* + +This example is to demonstrate how to: + +- Build a map for your current (device) location +- Update a virtual player's position and rotation based on a real or mock location and heading +- Use mock location providers to test in the Unity editor +- Convert between unity world space<—>earth space (latitude, longitude) + +The `LocationProvider` game object in this scene has three children. Each child corresponds to a specific type of `ILocationProvider`. Please [read more about LocationProviders](https://mapbox.github.io/mapbox-unity-sdk/api/unity/Mapbox.Unity.Location.html). + +The `MapController` game object has a `BuildMapAtLocation` component attached to it. This component is responsible for overriding the default center point of the `MapController` component, using the DefaultLocationProvider's location. In the Unity editor, this is the `EditorLocationProvider`—intended for mocking. On device, this is the `DeviceLocationProvider`—intended for real world location updates. + +To change the location for the map in the Editor, change `EditorLocationProvider`'s `LatitudeLongitude` field on the `Editor` game object. You can use the embedded `Search` button in the inspector to search for a place or address. The default location for this scene is the Metreon, in San Francisco, CA. + +**Note: It is important that the `MapController` component be disabled to begin with.** + +Press play and observe the map being constructed. Click on the `Player` game object and note the attached components: `PositionWithLocationProvider` and `RotateWithLocationProvider`. These are responsible for updating the transform's position and rotation based on a specified `ILocationProvider`. Again, in the `EditorLocationProvider`, search for `Yerba Buena Gardens` and select the top result. Watch as the player's position updates! + +If you check `Use Transform Location Provider` for `PositionWithLocationProvider` and `RotateWithLocationProvider`, the mock `ILocationProvider` will be represented by the `Transform` game object. Press play once more with this toggle checked for both components. In the scene view, move and rotate the `Transform` game object and observe as the `Player` tries to follow that target. It is important to note that the location returned by the `TransformLocationProvider` is actually converted from the transform's world position to latitude, longitude. This is what that conversion looks like: + +```cs +return _targetTransform.GetGeoPosition(MapController.ReferenceTileRect.Center, MapController.WorldScaleFactor); +``` + +If you build to device, you should see a familiar map and can observe the player update with your own location. Because the camera is a child of `Player`, you should always be centered on the map. + diff --git a/sdkproject/Assets/Mapbox/Core/Unity/Location.meta b/sdkproject/Assets/Mapbox/Core/Unity/Location.meta new file mode 100644 index 000000000..bd3ee01d3 --- /dev/null +++ b/sdkproject/Assets/Mapbox/Core/Unity/Location.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 8ef01f907e34d4888af041661232ec58 +folderAsset: yes +timeCreated: 1492101090 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/sdkproject/Assets/Mapbox/Core/Unity/Location/DeviceLocationProvider.cs b/sdkproject/Assets/Mapbox/Core/Unity/Location/DeviceLocationProvider.cs new file mode 100644 index 000000000..8bd94fffc --- /dev/null +++ b/sdkproject/Assets/Mapbox/Core/Unity/Location/DeviceLocationProvider.cs @@ -0,0 +1,140 @@ +namespace Mapbox.Unity.Location +{ + using System.Collections; + using UnityEngine; + using System; + using Mapbox.Utils; + + /// + /// The DeviceLocationProvider is responsible for providing real world location and heading data, + /// served directly from native hardware and OS. + /// This relies on Unity's LocationService for location + /// and Compass for heading. + /// + public class DeviceLocationProvider : MonoBehaviour, ILocationProvider + { + /// + /// Using higher value like 500 usually does not require to turn GPS chip on and thus saves battery power. + /// Values like 5-10 could be used for getting best accuracy. + /// + [SerializeField] + float _desiredAccuracyInMeters = 5f; + + /// + /// The minimum distance (measured in meters) a device must move laterally before Input.location property is updated. + /// Higher values like 500 imply less overhead. + /// + [SerializeField] + float _updateDistanceInMeters = 5f; + + Coroutine _pollRoutine; + + double _lastLocationTimestamp; + + double _lastHeadingTimestamp; + + WaitForSeconds _wait; + + Vector2d _location; + /// + /// Gets the current cached location. + /// + /// The location. + public Vector2d Location + { + get + { + return _location; + } + } + + /// + /// Occurs when on location updates. + /// + public event EventHandler OnLocationUpdated; + + /// + /// Occurs when the compass updates. + /// + public event EventHandler OnHeadingUpdated; + + void Start() + { + _wait = new WaitForSeconds(1f); + if (_pollRoutine == null) + { + _pollRoutine = StartCoroutine(PollLocationRoutine()); + } + } + + /// + /// Enable location and compass services. + /// Sends continuous location and heading updates based on + /// _desiredAccuracyInMeters and _updateDistanceInMeters. + /// + /// The location routine. + IEnumerator PollLocationRoutine() + { + if (!Input.location.isEnabledByUser) + { + yield break; + } + + Input.location.Start(_desiredAccuracyInMeters, _updateDistanceInMeters); + Input.compass.enabled = true; + + int maxWait = 20; + while (Input.location.status == LocationServiceStatus.Initializing && maxWait > 0) + { + yield return _wait; + maxWait--; + } + + if (maxWait < 1) + { + yield break; + } + + if (Input.location.status == LocationServiceStatus.Failed) + { + yield break; + } + + while (true) + { + var timestamp = Input.compass.timestamp; + if (Input.compass.enabled && timestamp > _lastHeadingTimestamp) + { + var heading = Input.compass.trueHeading; + SendHeadingUpdated(heading); + _lastHeadingTimestamp = timestamp; + } + + timestamp = Input.location.lastData.timestamp; + if (Input.location.status == LocationServiceStatus.Running && timestamp > _lastLocationTimestamp) + { + _location = new Vector2d(Input.location.lastData.latitude, Input.location.lastData.longitude); + SendLocationUpdated(_location); + _lastLocationTimestamp = timestamp; + } + yield return null; + } + } + + void SendHeadingUpdated(float heading) + { + if (OnHeadingUpdated != null) + { + OnHeadingUpdated(this, new HeadingUpdatedEventArgs() { Heading = heading }); + } + } + + void SendLocationUpdated(Vector2d location) + { + if (OnLocationUpdated != null) + { + OnLocationUpdated(this, new LocationUpdatedEventArgs() { Location = location }); + } + } + } +} \ No newline at end of file diff --git a/sdkproject/Assets/Mapbox/Core/Unity/Location/DeviceLocationProvider.cs.meta b/sdkproject/Assets/Mapbox/Core/Unity/Location/DeviceLocationProvider.cs.meta new file mode 100644 index 000000000..8b9422519 --- /dev/null +++ b/sdkproject/Assets/Mapbox/Core/Unity/Location/DeviceLocationProvider.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 0a38712e93231418a84665190b8473d0 +timeCreated: 1484075762 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sdkproject/Assets/Mapbox/Core/Unity/Location/EditorLocationProvider.cs b/sdkproject/Assets/Mapbox/Core/Unity/Location/EditorLocationProvider.cs new file mode 100644 index 000000000..c8cdf7e87 --- /dev/null +++ b/sdkproject/Assets/Mapbox/Core/Unity/Location/EditorLocationProvider.cs @@ -0,0 +1,77 @@ +namespace Mapbox.Unity.Location +{ + using System; + using Mapbox.Unity.Utilities; + using Mapbox.Utils; + using UnityEngine; + + /// + /// The EditorLocationProvider is responsible for providing mock location and heading data + /// for testing purposes in the Unity editor. + /// + public class EditorLocationProvider : MonoBehaviour, ILocationProvider + { + /// + /// The mock "latitude, longitude" location, respresented with a string. + /// You can search for a place using the embedded "Search" button in the inspector. + /// This value can be changed at runtime in the inspector. + /// + [SerializeField] + [Geocode] + string _latitudeLongitude; + + /// + /// The mock heading value. + /// + [SerializeField] + [Range(0, 359)] + float _heading; + + /// + /// Gets the current location, as specified in the inspector. + /// + /// The location. + public Vector2d Location + { + get + { + var split = _latitudeLongitude.Split(','); + return new Vector2d(double.Parse(split[0]), double.Parse(split[1])); + } + } + + /// + /// Occurs every frame. + /// + public event EventHandler OnHeadingUpdated; + + /// + /// Occurs every frame. + /// + public event EventHandler OnLocationUpdated; + +#if UNITY_EDITOR + void Update() + { + SendHeadingUpdated(); + SendLocationUpdated(); + } +#endif + + void SendHeadingUpdated() + { + if (OnHeadingUpdated != null) + { + OnHeadingUpdated(this, new HeadingUpdatedEventArgs() { Heading = _heading }); + } + } + + void SendLocationUpdated() + { + if (OnLocationUpdated != null) + { + OnLocationUpdated(this, new LocationUpdatedEventArgs() { Location = Location }); + } + } + } +} diff --git a/sdkproject/Assets/Mapbox/Core/Unity/Location/EditorLocationProvider.cs.meta b/sdkproject/Assets/Mapbox/Core/Unity/Location/EditorLocationProvider.cs.meta new file mode 100644 index 000000000..1a3c27e81 --- /dev/null +++ b/sdkproject/Assets/Mapbox/Core/Unity/Location/EditorLocationProvider.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 60712efc3153a4819b0c79437175846d +timeCreated: 1484085721 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sdkproject/Assets/Mapbox/Core/Unity/Location/ILocationProvider.cs b/sdkproject/Assets/Mapbox/Core/Unity/Location/ILocationProvider.cs new file mode 100644 index 000000000..d31c00327 --- /dev/null +++ b/sdkproject/Assets/Mapbox/Core/Unity/Location/ILocationProvider.cs @@ -0,0 +1,37 @@ +namespace Mapbox.Unity.Location +{ + using System; + using Mapbox.Utils; + + /// + /// Implement ILocationProvider to send Heading and Location updates. + /// + public interface ILocationProvider + { + event EventHandler OnLocationUpdated; + event EventHandler OnHeadingUpdated; + Vector2d Location { get; } + } + + /// + /// Location updated event arguments. + /// + public class LocationUpdatedEventArgs : EventArgs + { + /// + /// The location, as descibed by a . + /// Location.x represents Latitude. + /// Location.y represents Longitude. + /// + public Vector2d Location; + } + + /// + /// Heading updated event arguments. + /// Heading represents a facing angle, generally between 0-359. + /// + public class HeadingUpdatedEventArgs : EventArgs + { + public float Heading; + } +} diff --git a/sdkproject/Assets/Mapbox/Core/Unity/Location/ILocationProvider.cs.meta b/sdkproject/Assets/Mapbox/Core/Unity/Location/ILocationProvider.cs.meta new file mode 100644 index 000000000..e4fab6c3f --- /dev/null +++ b/sdkproject/Assets/Mapbox/Core/Unity/Location/ILocationProvider.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 7acec3aa2711f4ec0894a6d98ee70436 +timeCreated: 1484081764 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sdkproject/Assets/Mapbox/Core/Unity/Location/LocationProviderFactory.cs b/sdkproject/Assets/Mapbox/Core/Unity/Location/LocationProviderFactory.cs new file mode 100644 index 000000000..3d838dece --- /dev/null +++ b/sdkproject/Assets/Mapbox/Core/Unity/Location/LocationProviderFactory.cs @@ -0,0 +1,145 @@ +#if !UNITY_EDITOR +#define NOT_UNITY_EDITOR +#endif + +namespace Mapbox.Unity.Location +{ + using System.Diagnostics; + using UnityEngine; + + /// + /// Singleton factory to allow easy access to various LocationProviders. + /// This is meant to be attached to a game object. + /// + public class LocationProviderFactory : MonoBehaviour + { + [SerializeField] + DeviceLocationProvider _deviceLocationProvider; + + [SerializeField] + EditorLocationProvider _editorLocationProvider; + + [SerializeField] + TransformLocationProvider _transformLocationProvider; + + /// + /// The singleton instance of this factory. + /// + private static LocationProviderFactory _instance; + public static LocationProviderFactory Instance + { + get + { + return _instance; + } + + private set + { + _instance = value; + } + } + + ILocationProvider _defaultLocationProvider; + + /// + /// The default location provider. + /// Outside of the editor, this will be a . + /// In the Unity editor, this will be an + /// + /// + /// Fetch location to set a transform's position: + /// + /// void Update() + /// { + /// var locationProvider = LocationProviderFactory.Instance.DefaultLocationProvider; + /// transform.position = Conversions.GeoToWorldPosition(locationProvider.Location, + /// MapController.ReferenceTileRect.Center, + /// MapController.WorldScaleFactor).ToVector3xz(); + /// } + /// + /// + public ILocationProvider DefaultLocationProvider + { + get + { + return _defaultLocationProvider; + } + set + { + _defaultLocationProvider = value; + } + } + + /// + /// Returns the serialized . + /// + public TransformLocationProvider TransformLocationProvider + { + get + { + return _transformLocationProvider; + } + } + + /// + /// Returns the serialized . + /// + public EditorLocationProvider EditorLocationProvider + { + get + { + return _editorLocationProvider; + } + } + + /// + /// Returns the serialized + /// + public DeviceLocationProvider DeviceLocationProvider + { + get + { + return _deviceLocationProvider; + } + } + + /// + /// Create singleton instance and inject the DefaultLocationProvider upon initialization of this component. + /// + private void Awake() + { + if (Instance != null) + { + DestroyImmediate(gameObject); + return; + } + Instance = this; + DontDestroyOnLoad(gameObject); + + InjectEditorLocationProvider(); + InjectDeviceLocationProvider(); + } + + /// + /// Injects the editor location provider. + /// Depending on the platform, this method and calls to it will be stripped during compile. + /// + [Conditional("UNITY_EDITOR")] + void InjectEditorLocationProvider() + { + UnityEngine.Debug.Log("LocationProviderFactory: " + "Injected EDITOR Location Provider"); + DefaultLocationProvider = _editorLocationProvider; + } + + /// + /// Injects the device location provider. + /// Depending on the platform, this method and calls to it will be stripped during compile. + /// + [Conditional("NOT_UNITY_EDITOR")] + void InjectDeviceLocationProvider() + { + UnityEngine.Debug.Log("LocationProviderFactory: " + "Injected DEVICE Location Provider"); + DefaultLocationProvider = _deviceLocationProvider; + } + } +} diff --git a/sdkproject/Assets/Mapbox/Core/Unity/Location/LocationProviderFactory.cs.meta b/sdkproject/Assets/Mapbox/Core/Unity/Location/LocationProviderFactory.cs.meta new file mode 100644 index 000000000..b8cecedd4 --- /dev/null +++ b/sdkproject/Assets/Mapbox/Core/Unity/Location/LocationProviderFactory.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b55f37f9a6f7e44f7bb35e6bc3863847 +timeCreated: 1484256054 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sdkproject/Assets/Mapbox/Core/Unity/Location/TransformLocationProvider.cs b/sdkproject/Assets/Mapbox/Core/Unity/Location/TransformLocationProvider.cs new file mode 100644 index 000000000..3a8b6e2d5 --- /dev/null +++ b/sdkproject/Assets/Mapbox/Core/Unity/Location/TransformLocationProvider.cs @@ -0,0 +1,80 @@ +namespace Mapbox.Unity.Location +{ + using System; + using Mapbox.Unity.Utilities; + using Mapbox.Utils; + using UnityEngine; + using Mapbox.Unity.MeshGeneration; + + /// + /// The TransformLocationProvider is responsible for providing mock location and heading data + /// for testing purposes in the Unity editor. + /// This is achieved by querying a Unity Transform every frame. + /// You might use this to to update location based on a touched position, for example. + /// + public class TransformLocationProvider : MonoBehaviour, ILocationProvider + { + /// + /// The transform that will be queried for location and heading data. + /// + [SerializeField] + Transform _targetTransform; + + /// + /// Gets the latitude, longitude of the transform. + /// This is converted from unity world space to real world geocoordinate space. + /// + /// The location. + public Vector2d Location + { + get + { + return GetLocation(); + } + } + + /// + /// Sets the target transform. + /// Use this if you want to switch the transform at runtime. + /// + public Transform TargetTransform + { + set + { + _targetTransform = value; + } + } + + /// + /// Occurs every frame. + /// + public event EventHandler OnHeadingUpdated; + + /// + /// Occurs every frame. + /// + public event EventHandler OnLocationUpdated; + + void Update() + { + if (OnHeadingUpdated != null) + { + OnHeadingUpdated(this, new HeadingUpdatedEventArgs() { Heading = _targetTransform.eulerAngles.y }); + } + + if (OnLocationUpdated != null) + { + OnLocationUpdated(this, new LocationUpdatedEventArgs() { Location = GetLocation() }); + } + } + + Vector2d GetLocation() + { + if (MapController.ReferenceTileRect == null) + { + return LocationProviderFactory.Instance.DefaultLocationProvider.Location; + } + return _targetTransform.GetGeoPosition(MapController.ReferenceTileRect.Center, MapController.WorldScaleFactor); + } + } +} diff --git a/sdkproject/Assets/Mapbox/Core/Unity/Location/TransformLocationProvider.cs.meta b/sdkproject/Assets/Mapbox/Core/Unity/Location/TransformLocationProvider.cs.meta new file mode 100644 index 000000000..eb81eef59 --- /dev/null +++ b/sdkproject/Assets/Mapbox/Core/Unity/Location/TransformLocationProvider.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a034c4eeb3293418aab101c1895844a4 +timeCreated: 1484087415 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sdkproject/Assets/Mapbox/Core/Unity/Utilities/Conversions.cs b/sdkproject/Assets/Mapbox/Core/Unity/Utilities/Conversions.cs index 7f24816d1..ce927b1d1 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/Utilities/Conversions.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/Utilities/Conversions.cs @@ -56,6 +56,11 @@ public static Vector2d GeoToWorldPosition(double lat, double lon, Vector2d refPo return new Vector2d((posx - refPoint.x) * scale, (posy - refPoint.y) * scale); } + public static Vector2d GeoToWorldPosition(Vector2d latLong, Vector2d refPoint, float scale = 1) + { + return GeoToWorldPosition(latLong.x, latLong.y, refPoint, scale); + } + /// /// Converts Spherical Mercator EPSG:900913 in xy meters to WGS84 lat/lon. /// Inverse of LatLonToMeters. diff --git a/sdkproject/Assets/Mapbox/Examples/LocationProvider.meta b/sdkproject/Assets/Mapbox/Examples/LocationProvider.meta new file mode 100644 index 000000000..c32017342 --- /dev/null +++ b/sdkproject/Assets/Mapbox/Examples/LocationProvider.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 22e2a172b526d4e3bafd40f5f586d756 +folderAsset: yes +timeCreated: 1492113123 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/sdkproject/Assets/Mapbox/Examples/LocationProvider/LocationProvider.unity b/sdkproject/Assets/Mapbox/Examples/LocationProvider/LocationProvider.unity new file mode 100644 index 000000000..67eb06d75 --- /dev/null +++ b/sdkproject/Assets/Mapbox/Examples/LocationProvider/LocationProvider.unity @@ -0,0 +1,547 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +SceneSettings: + m_ObjectHideFlags: 0 + m_PVSData: + m_PVSObjectsArray: [] + m_PVSPortalsArray: [] + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 7 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0.37356392, g: 0.38112, b: 0.3588766, a: 1} +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 7 + m_GIWorkflowMode: 0 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 4 + m_Resolution: 2 + m_BakeResolution: 40 + m_TextureWidth: 1024 + m_TextureHeight: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_DirectLightInLightProbes: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_LightingDataAsset: {fileID: 0} + m_RuntimeCPUUsage: 25 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + accuratePlacement: 0 + minRegionArea: 2 + cellSize: 0.16666667 + manualCellSize: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &114606470 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 114606472} + - 114: {fileID: 114606471} + - 114: {fileID: 114606473} + m_Layer: 0 + m_Name: MapController + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &114606471 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 114606470} + m_Enabled: 0 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c57173fef834bb94098b65581fb4f0e4, type: 3} + m_Name: + m_EditorClassIdentifier: + MapVisualization: {fileID: 11400000, guid: 38f8ab26621bb424d86f009e3dce979f, type: 2} + TileSize: 100 + _snapYToZero: 0 + LatLng: 37.7648, -122.463 + Zoom: 15 + Range: {x: 1, y: 1, z: 1, w: 1} +--- !u!4 &114606472 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 114606470} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 +--- !u!114 &114606473 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 114606470} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3fdc49f4b978b4412949e77a41421ee2, type: 3} + m_Name: + m_EditorClassIdentifier: + _mapController: {fileID: 114606471} +--- !u!1 &354925210 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 354925211} + - 33: {fileID: 354925214} + - 65: {fileID: 354925213} + - 23: {fileID: 354925212} + m_Layer: 0 + m_Name: Cube + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &354925211 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 354925210} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 2, z: 0} + m_LocalScale: {x: 1, y: 4, z: 1} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_Children: [] + m_Father: {fileID: 1934621224} + m_RootOrder: 0 +--- !u!23 &354925212 +MeshRenderer: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 354925210} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 0} + m_SubsetIndices: + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 1 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_SelectedWireframeHidden: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingOrder: 0 +--- !u!65 &354925213 +BoxCollider: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 354925210} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0, z: 0} +--- !u!33 &354925214 +MeshFilter: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 354925210} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!1 &433510106 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 433510108} + - 114: {fileID: 433510107} + m_Layer: 0 + m_Name: LocationProvider + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &433510107 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 433510106} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b55f37f9a6f7e44f7bb35e6bc3863847, type: 3} + m_Name: + m_EditorClassIdentifier: + _deviceLocationProvider: {fileID: 1098163516} + _editorLocationProvider: {fileID: 1628209262} + _transformLocationProvider: {fileID: 1649127105} +--- !u!4 &433510108 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 433510106} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_Children: + - {fileID: 1098163517} + - {fileID: 1628209263} + - {fileID: 1649127106} + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!1 &580608870 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 580608875} + - 20: {fileID: 580608874} + - 92: {fileID: 580608873} + - 124: {fileID: 580608872} + - 81: {fileID: 580608871} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &580608871 +AudioListener: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 580608870} + m_Enabled: 1 +--- !u!124 &580608872 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 580608870} + m_Enabled: 1 +--- !u!92 &580608873 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 580608870} + m_Enabled: 1 +--- !u!20 &580608874 +Camera: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 580608870} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 + m_StereoMirrorMode: 0 +--- !u!4 &580608875 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 580608870} + m_LocalRotation: {x: 0.5735764, y: 0, z: 0, w: 0.8191521} + m_LocalPosition: {x: 0, y: 25, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_LocalEulerAnglesHint: {x: 70, y: 0, z: 0} + m_Children: [] + m_Father: {fileID: 1934621224} + m_RootOrder: 1 +--- !u!1 &1098163515 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 1098163517} + - 114: {fileID: 1098163516} + m_Layer: 0 + m_Name: Device + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1098163516 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1098163515} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0a38712e93231418a84665190b8473d0, type: 3} + m_Name: + m_EditorClassIdentifier: + _desiredAccuracyInMeters: 5 + _updateDistanceInMeters: 5 +--- !u!4 &1098163517 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1098163515} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_Children: [] + m_Father: {fileID: 433510108} + m_RootOrder: 0 +--- !u!1 &1628209261 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 1628209263} + - 114: {fileID: 1628209262} + m_Layer: 0 + m_Name: Editor + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1628209262 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1628209261} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 60712efc3153a4819b0c79437175846d, type: 3} + m_Name: + m_EditorClassIdentifier: + _latitudeLongitude: 37.784328, -122.40364 + _heading: 0 +--- !u!4 &1628209263 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1628209261} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_Children: [] + m_Father: {fileID: 433510108} + m_RootOrder: 1 +--- !u!1 &1649127104 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 1649127106} + - 114: {fileID: 1649127105} + m_Layer: 0 + m_Name: Transform + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1649127105 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1649127104} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a034c4eeb3293418aab101c1895844a4, type: 3} + m_Name: + m_EditorClassIdentifier: + _targetTransform: {fileID: 1649127106} +--- !u!4 &1649127106 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1649127104} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_Children: [] + m_Father: {fileID: 433510108} + m_RootOrder: 2 +--- !u!1 &1934621221 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 1934621224} + - 114: {fileID: 1934621223} + - 114: {fileID: 1934621222} + m_Layer: 0 + m_Name: Player + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1934621222 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1934621221} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 061d2afb48ace4fd19611279b6cf732f, type: 3} + m_Name: + m_EditorClassIdentifier: + _rotationFollowFactor: 2 + _rotateZ: 0 + _useTransformLocationProvider: 0 +--- !u!114 &1934621223 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1934621221} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4bb39d89f6f3742418be7c93b4259637, type: 3} + m_Name: + m_EditorClassIdentifier: + _positionFollowFactor: 0.5 + _useTransformLocationProvider: 0 +--- !u!4 &1934621224 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1934621221} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_Children: + - {fileID: 354925211} + - {fileID: 580608875} + m_Father: {fileID: 0} + m_RootOrder: 2 diff --git a/sdkproject/Assets/Mapbox/Examples/LocationProvider/LocationProvider.unity.meta b/sdkproject/Assets/Mapbox/Examples/LocationProvider/LocationProvider.unity.meta new file mode 100644 index 000000000..5696e38e1 --- /dev/null +++ b/sdkproject/Assets/Mapbox/Examples/LocationProvider/LocationProvider.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3f89098a339c744e88644a47f777dbf9 +timeCreated: 1492113148 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/sdkproject/Assets/Mapbox/Examples/LocationProvider/MapVisualization.meta b/sdkproject/Assets/Mapbox/Examples/LocationProvider/MapVisualization.meta new file mode 100644 index 000000000..c1657c2ea --- /dev/null +++ b/sdkproject/Assets/Mapbox/Examples/LocationProvider/MapVisualization.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 4f208f9ae62a4460fb9b729033d4c174 +folderAsset: yes +timeCreated: 1492114600 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/sdkproject/Assets/Mapbox/Examples/LocationProvider/MapVisualization/LocationProviderMapImageFactory.asset b/sdkproject/Assets/Mapbox/Examples/LocationProvider/MapVisualization/LocationProviderMapImageFactory.asset new file mode 100644 index 000000000..ab24fc2e5 --- /dev/null +++ b/sdkproject/Assets/Mapbox/Examples/LocationProvider/MapVisualization/LocationProviderMapImageFactory.asset @@ -0,0 +1,17 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2b10536479dade041b6db9893fdf723a, type: 3} + m_Name: LocationProviderMapImageFactory + m_EditorClassIdentifier: + _mapIdType: 0 + _customMapId: + _mapId: mapbox://styles/mapbox/outdoors-v10 + _baseMaterial: {fileID: 2100000, guid: 8ba055cb55bcc4488b727c601be0be29, type: 2} diff --git a/sdkproject/Assets/Mapbox/Examples/LocationProvider/MapVisualization/LocationProviderMapImageFactory.asset.meta b/sdkproject/Assets/Mapbox/Examples/LocationProvider/MapVisualization/LocationProviderMapImageFactory.asset.meta new file mode 100644 index 000000000..9a8a20da3 --- /dev/null +++ b/sdkproject/Assets/Mapbox/Examples/LocationProvider/MapVisualization/LocationProviderMapImageFactory.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 70ae1b4720c0f4f3d8bd4e48b43f6945 +timeCreated: 1492114655 +licenseType: Pro +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/sdkproject/Assets/Mapbox/Examples/LocationProvider/MapVisualization/LocationProviderMapMaterial.mat b/sdkproject/Assets/Mapbox/Examples/LocationProvider/MapVisualization/LocationProviderMapMaterial.mat new file mode 100644 index 000000000..1243acabd --- /dev/null +++ b/sdkproject/Assets/Mapbox/Examples/LocationProvider/MapVisualization/LocationProviderMapMaterial.mat @@ -0,0 +1,127 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: LocationProviderMapMaterial + m_Shader: {fileID: 10752, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: _EMISSION + m_LightmapFlags: 1 + m_CustomRenderQueue: -1 + stringTagMap: {} + m_SavedProperties: + serializedVersion: 2 + m_TexEnvs: + - first: + name: _BumpMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - first: + name: _DetailAlbedoMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - first: + name: _DetailMask + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - first: + name: _DetailNormalMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - first: + name: _EmissionMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - first: + name: _MainTex + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - first: + name: _MetallicGlossMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - first: + name: _OcclusionMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - first: + name: _ParallaxMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - first: + name: _BumpScale + second: 1 + - first: + name: _Cutoff + second: 0.5 + - first: + name: _DetailNormalMapScale + second: 1 + - first: + name: _DstBlend + second: 0 + - first: + name: _GlossMapScale + second: 1 + - first: + name: _Glossiness + second: 0.5 + - first: + name: _GlossyReflections + second: 1 + - first: + name: _Metallic + second: 0 + - first: + name: _Mode + second: 0 + - first: + name: _OcclusionStrength + second: 1 + - first: + name: _Parallax + second: 0.02 + - first: + name: _SmoothnessTextureChannel + second: 0 + - first: + name: _SpecularHighlights + second: 1 + - first: + name: _SrcBlend + second: 1 + - first: + name: _UVSec + second: 0 + - first: + name: _ZWrite + second: 1 + m_Colors: + - first: + name: _Color + second: {r: 1, g: 1, b: 1, a: 1} + - first: + name: _EmissionColor + second: {r: 0, g: 0, b: 0, a: 1} diff --git a/sdkproject/Assets/Mapbox/Examples/LocationProvider/MapVisualization/LocationProviderMapMaterial.mat.meta b/sdkproject/Assets/Mapbox/Examples/LocationProvider/MapVisualization/LocationProviderMapMaterial.mat.meta new file mode 100644 index 000000000..eb934f414 --- /dev/null +++ b/sdkproject/Assets/Mapbox/Examples/LocationProvider/MapVisualization/LocationProviderMapMaterial.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8ba055cb55bcc4488b727c601be0be29 +timeCreated: 1492114686 +licenseType: Pro +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/sdkproject/Assets/Mapbox/Examples/LocationProvider/MapVisualization/LocationProviderTerrainFactory.asset b/sdkproject/Assets/Mapbox/Examples/LocationProvider/MapVisualization/LocationProviderTerrainFactory.asset new file mode 100644 index 000000000..8c8325d3d --- /dev/null +++ b/sdkproject/Assets/Mapbox/Examples/LocationProvider/MapVisualization/LocationProviderTerrainFactory.asset @@ -0,0 +1,20 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 8338f26893d62c1439f387800a8e1c9a, type: 3} + m_Name: LocationProviderTerrainFactory + m_EditorClassIdentifier: + _generationType: 0 + _baseMaterial: {fileID: 0} + _mapIdType: 0 + _customMapId: mapbox.terrain-rgb + _mapId: + _heightModifier: 1 + _sampleCount: 2 diff --git a/sdkproject/Assets/Mapbox/Examples/LocationProvider/MapVisualization/LocationProviderTerrainFactory.asset.meta b/sdkproject/Assets/Mapbox/Examples/LocationProvider/MapVisualization/LocationProviderTerrainFactory.asset.meta new file mode 100644 index 000000000..6ea3244c8 --- /dev/null +++ b/sdkproject/Assets/Mapbox/Examples/LocationProvider/MapVisualization/LocationProviderTerrainFactory.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 82b1ecdf2417242a98d0f32cb1cea955 +timeCreated: 1492114634 +licenseType: Pro +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/sdkproject/Assets/Mapbox/Examples/LocationProvider/MapVisualization/LocationProviderVisualization.asset b/sdkproject/Assets/Mapbox/Examples/LocationProvider/MapVisualization/LocationProviderVisualization.asset new file mode 100644 index 000000000..02393f71c --- /dev/null +++ b/sdkproject/Assets/Mapbox/Examples/LocationProvider/MapVisualization/LocationProviderVisualization.asset @@ -0,0 +1,16 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c66bbffbe36286f43ba04d55504d674c, type: 3} + m_Name: LocationProviderVisualization + m_EditorClassIdentifier: + Factories: + - {fileID: 11400000, guid: 82b1ecdf2417242a98d0f32cb1cea955, type: 2} + - {fileID: 11400000, guid: 70ae1b4720c0f4f3d8bd4e48b43f6945, type: 2} diff --git a/sdkproject/Assets/Mapbox/Examples/LocationProvider/MapVisualization/LocationProviderVisualization.asset.meta b/sdkproject/Assets/Mapbox/Examples/LocationProvider/MapVisualization/LocationProviderVisualization.asset.meta new file mode 100644 index 000000000..6c7077fd8 --- /dev/null +++ b/sdkproject/Assets/Mapbox/Examples/LocationProvider/MapVisualization/LocationProviderVisualization.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 38f8ab26621bb424d86f009e3dce979f +timeCreated: 1492114615 +licenseType: Pro +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/sdkproject/Assets/Mapbox/Examples/LocationProvider/Scripts.meta b/sdkproject/Assets/Mapbox/Examples/LocationProvider/Scripts.meta new file mode 100644 index 000000000..2d5378c20 --- /dev/null +++ b/sdkproject/Assets/Mapbox/Examples/LocationProvider/Scripts.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: ce38eef23ab1e4f4fbbb5476587f7eff +folderAsset: yes +timeCreated: 1492115016 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/sdkproject/Assets/Mapbox/Examples/LocationProvider/Scripts/BuildMapAtLocation.cs b/sdkproject/Assets/Mapbox/Examples/LocationProvider/Scripts/BuildMapAtLocation.cs new file mode 100644 index 000000000..8d73ef353 --- /dev/null +++ b/sdkproject/Assets/Mapbox/Examples/LocationProvider/Scripts/BuildMapAtLocation.cs @@ -0,0 +1,42 @@ +namespace Mapbox.Examples.LocationProvider +{ + using UnityEngine; + using Mapbox.Unity.MeshGeneration; + using Mapbox.Unity.Location; + + /// + /// Override the map center (latitude, longitude) for a MapController, based on the DefaultLocationProvider. + /// This will enable you to generate a map for your current location, for example. + /// + public class BuildMapAtLocation : MonoBehaviour + { + [SerializeField] + MapController _mapController; + + ILocationProvider _locationProvider; + ILocationProvider LocationProvider + { + get + { + if (_locationProvider == null) + { + _locationProvider = LocationProviderFactory.Instance.DefaultLocationProvider; + } + + return _locationProvider; + } + } + + void Start() + { + LocationProvider.OnLocationUpdated += LocationProvider_OnLocationUpdated; + } + + void LocationProvider_OnLocationUpdated(object sender, Unity.Location.LocationUpdatedEventArgs e) + { + LocationProvider.OnLocationUpdated -= LocationProvider_OnLocationUpdated; + _mapController.LatLng = string.Format("{0}, {1}", e.Location.x, e.Location.y); + _mapController.enabled = true; + } + } +} \ No newline at end of file diff --git a/sdkproject/Assets/Mapbox/Examples/LocationProvider/Scripts/BuildMapAtLocation.cs.meta b/sdkproject/Assets/Mapbox/Examples/LocationProvider/Scripts/BuildMapAtLocation.cs.meta new file mode 100644 index 000000000..5c7bab472 --- /dev/null +++ b/sdkproject/Assets/Mapbox/Examples/LocationProvider/Scripts/BuildMapAtLocation.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 3fdc49f4b978b4412949e77a41421ee2 +timeCreated: 1492184286 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sdkproject/Assets/Mapbox/Examples/LocationProvider/Scripts/PositionWithLocationProvider.cs b/sdkproject/Assets/Mapbox/Examples/LocationProvider/Scripts/PositionWithLocationProvider.cs new file mode 100644 index 000000000..84d5aaeb0 --- /dev/null +++ b/sdkproject/Assets/Mapbox/Examples/LocationProvider/Scripts/PositionWithLocationProvider.cs @@ -0,0 +1,84 @@ +namespace Mapbox.Examples.LocationProvider +{ + using Mapbox.Unity.Location; + using Mapbox.Unity.Utilities; + using Mapbox.Unity.MeshGeneration; + using UnityEngine; + + public class PositionWithLocationProvider : MonoBehaviour + { + /// + /// The rate at which the transform's position tries catch up to the provided location. + /// + [SerializeField] + float _positionFollowFactor; + + /// + /// Use a mock , + /// rather than a . + /// + [SerializeField] + bool _useTransformLocationProvider; + + /// + /// The location provider. + /// This is public so you change which concrete to use at runtime. + /// + ILocationProvider _locationProvider; + public ILocationProvider LocationProvider + { + private get + { + if (_locationProvider == null) + { + _locationProvider = _useTransformLocationProvider ? + LocationProviderFactory.Instance.TransformLocationProvider : LocationProviderFactory.Instance.DefaultLocationProvider; + } + + return _locationProvider; + } + set + { + if (_locationProvider != null) + { + _locationProvider.OnLocationUpdated -= LocationProvider_OnLocationUpdated; + + } + _locationProvider = value; + _locationProvider.OnLocationUpdated += LocationProvider_OnLocationUpdated; + } + } + + Vector3 _targetPosition; + + void Start() + { + LocationProvider.OnLocationUpdated += LocationProvider_OnLocationUpdated; + } + + void OnDestroy() + { + if (LocationProvider != null) + { + LocationProvider.OnLocationUpdated -= LocationProvider_OnLocationUpdated; + } + } + + void LocationProvider_OnLocationUpdated(object sender, LocationUpdatedEventArgs e) + { + if (MapController.ReferenceTileRect == null) + { + return; + } + + _targetPosition = Conversions.GeoToWorldPosition(e.Location, + MapController.ReferenceTileRect.Center, + MapController.WorldScaleFactor).ToVector3xz(); + } + + void Update() + { + transform.position = Vector3.Lerp(transform.position, _targetPosition, Time.deltaTime * _positionFollowFactor); + } + } +} diff --git a/sdkproject/Assets/Mapbox/Examples/LocationProvider/Scripts/PositionWithLocationProvider.cs.meta b/sdkproject/Assets/Mapbox/Examples/LocationProvider/Scripts/PositionWithLocationProvider.cs.meta new file mode 100644 index 000000000..d463b002f --- /dev/null +++ b/sdkproject/Assets/Mapbox/Examples/LocationProvider/Scripts/PositionWithLocationProvider.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 4bb39d89f6f3742418be7c93b4259637 +timeCreated: 1492115167 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sdkproject/Assets/Mapbox/Examples/LocationProvider/Scripts/RotateWithLocationProvider.cs b/sdkproject/Assets/Mapbox/Examples/LocationProvider/Scripts/RotateWithLocationProvider.cs new file mode 100644 index 000000000..2459994be --- /dev/null +++ b/sdkproject/Assets/Mapbox/Examples/LocationProvider/Scripts/RotateWithLocationProvider.cs @@ -0,0 +1,87 @@ +namespace Mapbox.Examples.LocationProvider +{ + using Mapbox.Unity.Location; + using UnityEngine; + + public class RotateWithLocationProvider : MonoBehaviour + { + /// + /// The rate at which the transform's rotation tries catch up to the provided heading. + /// + [SerializeField] + float _rotationFollowFactor; + + /// + /// Set this to true if you'd like to adjust the rotation of a RectTransform (in a UI canvas) with the heading. + /// + [SerializeField] + bool _rotateZ; + + /// + /// Use a mock , + /// rather than a . + /// + [SerializeField] + bool _useTransformLocationProvider; + + /// + /// The location provider. + /// This is public so you change which concrete to use at runtime. + /// + ILocationProvider _locationProvider; + public ILocationProvider LocationProvider + { + private get + { + if (_locationProvider == null) + { + _locationProvider = _useTransformLocationProvider ? + LocationProviderFactory.Instance.TransformLocationProvider : LocationProviderFactory.Instance.DefaultLocationProvider; + } + + return _locationProvider; + } + set + { + if (_locationProvider != null) + { + _locationProvider.OnHeadingUpdated -= LocationProvider_OnHeadingUpdated; + + } + _locationProvider = value; + _locationProvider.OnHeadingUpdated += LocationProvider_OnHeadingUpdated; + } + } + + Vector3 _targetPosition; + + void Start() + { + LocationProvider.OnHeadingUpdated += LocationProvider_OnHeadingUpdated; + } + + void OnDestroy() + { + if (LocationProvider != null) + { + LocationProvider.OnHeadingUpdated -= LocationProvider_OnHeadingUpdated; + } + } + + void LocationProvider_OnHeadingUpdated(object sender, HeadingUpdatedEventArgs e) + { + var euler = Vector3.zero; + if (_rotateZ) + { + euler.z = -e.Heading; + } + else + { + euler.y = e.Heading; + } + + var rotation = Quaternion.Euler(euler); + transform.localRotation = Quaternion.Lerp(transform.localRotation, rotation, Time.deltaTime * _rotationFollowFactor); + } + } +} diff --git a/sdkproject/Assets/Mapbox/Examples/LocationProvider/Scripts/RotateWithLocationProvider.cs.meta b/sdkproject/Assets/Mapbox/Examples/LocationProvider/Scripts/RotateWithLocationProvider.cs.meta new file mode 100644 index 000000000..766628f68 --- /dev/null +++ b/sdkproject/Assets/Mapbox/Examples/LocationProvider/Scripts/RotateWithLocationProvider.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 061d2afb48ace4fd19611279b6cf732f +timeCreated: 1492115182 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sdkproject/ProjectSettings/EditorBuildSettings.asset b/sdkproject/ProjectSettings/EditorBuildSettings.asset index 6dc24f7df..e8f9a8784 100644 --- a/sdkproject/ProjectSettings/EditorBuildSettings.asset +++ b/sdkproject/ProjectSettings/EditorBuildSettings.asset @@ -4,4 +4,6 @@ EditorBuildSettings: m_ObjectHideFlags: 0 serializedVersion: 2 - m_Scenes: [] + m_Scenes: + - enabled: 1 + path: Assets/Mapbox/Examples/LocationProvider/LocationProvider.unity diff --git a/sdkproject/ProjectSettings/GraphicsSettings.asset b/sdkproject/ProjectSettings/GraphicsSettings.asset index 325937ca8..d10340e38 100644 --- a/sdkproject/ProjectSettings/GraphicsSettings.asset +++ b/sdkproject/ProjectSettings/GraphicsSettings.asset @@ -40,20 +40,20 @@ GraphicsSettings: m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} m_ShaderSettings_Tier1: - useCascadedShadowMaps: 1 - standardShaderQuality: 2 - useReflectionProbeBoxProjection: 1 - useReflectionProbeBlending: 1 + useCascadedShadowMaps: 0 + standardShaderQuality: 0 + useReflectionProbeBoxProjection: 0 + useReflectionProbeBlending: 0 m_ShaderSettings_Tier2: - useCascadedShadowMaps: 1 - standardShaderQuality: 2 - useReflectionProbeBoxProjection: 1 - useReflectionProbeBlending: 1 + useCascadedShadowMaps: 0 + standardShaderQuality: 1 + useReflectionProbeBoxProjection: 0 + useReflectionProbeBlending: 0 m_ShaderSettings_Tier3: - useCascadedShadowMaps: 1 - standardShaderQuality: 2 - useReflectionProbeBoxProjection: 1 - useReflectionProbeBlending: 1 + useCascadedShadowMaps: 0 + standardShaderQuality: 1 + useReflectionProbeBoxProjection: 0 + useReflectionProbeBlending: 0 m_BuildTargetShaderSettings: [] m_LightmapStripping: 0 m_FogStripping: 0