[TASK] Initial commit with basic product setup
This commit is contained in:
55
Assets/Mapbox SDK/Mapbox/Unity/SourceLayers/AbstractLayer.cs
Normal file
55
Assets/Mapbox SDK/Mapbox/Unity/SourceLayers/AbstractLayer.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using Mapbox.Unity.MeshGeneration.Factories;
|
||||
using Mapbox.Unity.MeshGeneration.Interfaces;
|
||||
using Mapbox.Unity.MeshGeneration.Modifiers;
|
||||
|
||||
public class LayerUpdateArgs : System.EventArgs
|
||||
{
|
||||
public AbstractTileFactory factory;
|
||||
public MapboxDataProperty property;
|
||||
public bool effectsVectorLayer;
|
||||
}
|
||||
|
||||
public class VectorLayerUpdateArgs : LayerUpdateArgs
|
||||
{
|
||||
public LayerVisualizerBase visualizer;
|
||||
public ModifierBase modifier;
|
||||
}
|
||||
|
||||
public class AbstractLayer
|
||||
{
|
||||
public event System.EventHandler UpdateLayer;
|
||||
protected virtual void NotifyUpdateLayer(LayerUpdateArgs layerUpdateArgs)
|
||||
{
|
||||
System.EventHandler handler = UpdateLayer;
|
||||
if (handler != null)
|
||||
{
|
||||
handler(this, layerUpdateArgs);
|
||||
}
|
||||
}
|
||||
protected virtual void NotifyUpdateLayer(AbstractTileFactory factory, MapboxDataProperty prop, bool effectsVectorLayer = false)
|
||||
{
|
||||
System.EventHandler handler = UpdateLayer;
|
||||
if (handler != null)
|
||||
{
|
||||
LayerUpdateArgs layerUpdateArgs =
|
||||
(factory is VectorTileFactory) ?
|
||||
new VectorLayerUpdateArgs
|
||||
{
|
||||
factory = factory,
|
||||
effectsVectorLayer = effectsVectorLayer,
|
||||
property = prop
|
||||
}
|
||||
:
|
||||
new LayerUpdateArgs
|
||||
{
|
||||
factory = factory,
|
||||
effectsVectorLayer = effectsVectorLayer,
|
||||
property = prop
|
||||
};
|
||||
handler(this, layerUpdateArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 94d130e0e418e7042b9deff5b289346f
|
||||
timeCreated: 1533073579
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
53
Assets/Mapbox SDK/Mapbox/Unity/SourceLayers/IImageryLayer.cs
Normal file
53
Assets/Mapbox SDK/Mapbox/Unity/SourceLayers/IImageryLayer.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
public interface IImageryLayer : ILayer
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the `Data Source` for the `IMAGE` component.
|
||||
/// </summary>
|
||||
ImagerySourceType LayerSource { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Sets the `Data Source` for the `IMAGE` component. This can be one of the
|
||||
/// [Mapbox default styles](https://www.mapbox.com/api-documentation/#styles),
|
||||
/// or a custom style. The style url is set as the `Map ID`.
|
||||
/// </summary>
|
||||
/// <param name="imageSource">Source of imagery for map. Can be a Mapbox default, or custom style.</param>
|
||||
void SetLayerSource(ImagerySourceType imageSource);
|
||||
|
||||
/// <summary>
|
||||
/// Enables or disables high quality images for the specified Data Source.
|
||||
/// resoluion when enabled is 1024px, and 512px when disabled. Satellite
|
||||
/// imagery is 512px when enabled, and 256 px when disabled. Changes to this
|
||||
/// may not take effect until the cache is cleared.
|
||||
/// </summary>
|
||||
/// <param name="useRetina">Boolean to toggle `Use Retina`.</param>
|
||||
void UseRetina(bool useRetina);
|
||||
|
||||
/// <summary>
|
||||
/// Enables or disables Unity Texture2D compression for `IMAGE` outputs.
|
||||
/// Enable this if you need performance rather than a high resolution image.
|
||||
/// </summary>
|
||||
/// <param name="useCompression">Boolean to toggle `Use Compression`.</param>
|
||||
void UseCompression(bool useCompression);
|
||||
|
||||
/// <summary>
|
||||
/// Enables or disables Unity Texture2D Mipmap for `IMAGE` outputs.
|
||||
/// Mipmaps are lists of progressively smaller versions of an image, used
|
||||
/// to optimize performance. Enabling mipmaps consumes more memory, but
|
||||
/// provides improved performance.
|
||||
/// </summary>
|
||||
/// <param name="useMipMap">Boolean to toggle `Use Mip Map`.</param>
|
||||
void UseMipMap(bool useMipMap);
|
||||
|
||||
/// <summary>
|
||||
/// Changes the settings for the `IMAGE` component.
|
||||
/// </summary>
|
||||
/// <param name="imageSource">`Data Source` for the IMAGE component.</param>
|
||||
/// <param name="useRetina">Enables or disables high quality imagery.</param>
|
||||
/// <param name="useCompression">Enables or disables Unity Texture2D compression.</param>
|
||||
/// <param name="useMipMap">Enables or disables Unity Texture2D image mipmapping.</param>
|
||||
void SetProperties(ImagerySourceType imageSource, bool useRetina, bool useCompression, bool useMipMap);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 80a22b06fd73b4e009a924a0be131391
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
309
Assets/Mapbox SDK/Mapbox/Unity/SourceLayers/ILayer.cs
Normal file
309
Assets/Mapbox SDK/Mapbox/Unity/SourceLayers/ILayer.cs
Normal file
@@ -0,0 +1,309 @@
|
||||
using System.Linq;
|
||||
using Mapbox.Unity.SourceLayers;
|
||||
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Mapbox.Unity.MeshGeneration.Filters;
|
||||
using Mapbox.Utils;
|
||||
using UnityEngine;
|
||||
|
||||
public interface ILayer
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the type of feature from the `FEATURES` section.
|
||||
/// </summary>
|
||||
MapLayerType LayerType { get; }
|
||||
/// <summary>
|
||||
/// Boolean for setting the feature layer active or inactive.
|
||||
/// </summary>
|
||||
bool IsLayerActive { get; }
|
||||
/// <summary>
|
||||
/// Gets the source ID for the feature layer.
|
||||
/// </summary>
|
||||
string LayerSourceId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the `Data Source` for the `MAP LAYERS` section.
|
||||
/// </summary>
|
||||
void SetLayerSource(string source);
|
||||
void Initialize();
|
||||
void Initialize(LayerProperties properties);
|
||||
void Update(LayerProperties properties);
|
||||
void Remove();
|
||||
|
||||
}
|
||||
|
||||
public interface IVectorDataLayer : ILayer
|
||||
{
|
||||
#region Layer Level APIs
|
||||
TileJsonData GetTileJsonData();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the `Data Source` for the `MAP LAYERS` section.
|
||||
/// </summary>
|
||||
void SetLayerSource(VectorSourceType vectorSource);
|
||||
|
||||
/// <summary>
|
||||
/// Adds the provided `Data Source` (`Map ID`) to existing ones. For multiple
|
||||
/// sources, you can separate with a comma. `Map ID` string is added at the
|
||||
/// end of the existing sources.
|
||||
/// </summary>
|
||||
/// <param name="vectorSource">`Data Source` (`Map ID`) to add to existing sources.</param>
|
||||
void AddLayerSource(string vectorSource);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the layer source as Style-optimized vector tiles
|
||||
/// </summary>
|
||||
/// <param name="vectorSource">Vector source.</param>
|
||||
/// <param name="styleId">Style-Optimized style id.</param>
|
||||
/// <param name="modifiedDate">Modified date.</param>
|
||||
/// <param name="styleName">Style name.</param>
|
||||
void SetLayerSourceWithOptimizedStyle(string vectorSource, string styleId, string modifiedDate, string styleName = null);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the layer source as Style-optimized vector tiles
|
||||
/// </summary>
|
||||
/// <param name="vectorSource">Vector source.</param>
|
||||
/// <param name="styleId">Style-Optimized style id.</param>
|
||||
/// <param name="modifiedDate">Modified date.</param>
|
||||
/// <param name="styleName">Style name.</param>
|
||||
void SetLayerSourceWithOptimizedStyle(VectorSourceType vectorSource, string styleId, string modifiedDate, string styleName = null);
|
||||
|
||||
/// <summary>
|
||||
/// Enables coroutines for vector features. Processes the specified amount
|
||||
/// of them each frame.
|
||||
/// </summary>
|
||||
/// <param name="entityPerCoroutine">Numbers of features to process each frame.</param>
|
||||
void EnableVectorFeatureProcessingWithCoroutines(int entityPerCoroutine = 20);
|
||||
|
||||
/// <summary>
|
||||
/// Disables processing of vector features on coroutines.
|
||||
/// </summary>
|
||||
void DisableVectorFeatureProcessingWithCoroutines();
|
||||
#endregion
|
||||
|
||||
#region LayerOperations
|
||||
|
||||
// FEATURE LAYER OPERATIONS
|
||||
|
||||
void AddFeatureSubLayer(VectorSubLayerProperties subLayerProperties);
|
||||
|
||||
/// <summary>
|
||||
/// Adds a sub layer to render polygon features.
|
||||
/// Default settings include :
|
||||
/// Extrusion = true
|
||||
/// ExtrusionType = PropertyHeight
|
||||
/// ExtrusionGeometryType = Roof And Sides
|
||||
/// Testuring = Realistic.
|
||||
/// </summary>
|
||||
/// <param name="assignedSubLayerName">Assigned sub layer name.</param>
|
||||
/// <param name="dataLayerNameInService">Data layer name in service.</param>
|
||||
void AddPolygonFeatureSubLayer(string assignedSubLayerName, string dataLayerNameInService);
|
||||
|
||||
/// <summary>
|
||||
/// Adds a sub layer to render line features.
|
||||
/// Default settings include :
|
||||
/// LineWidth = 1
|
||||
/// Extrusion = true
|
||||
/// ExtrusionType = AbsoluteHeight
|
||||
/// ExtrusionGeometryType = Roof And Sides
|
||||
/// Testuring = Dark.
|
||||
/// </summary>
|
||||
/// <param name="assignedSubLayerName">Assigned sub layer name.</param>
|
||||
/// <param name="dataLayerNameInService">Data layer name in service.</param>
|
||||
/// <param name="lineWidth">Line width.</param>
|
||||
void AddLineFeatureSubLayer(string assignedSubLayerName, string dataLayerNameInService, float lineWidth = 1);
|
||||
|
||||
/// <summary>
|
||||
/// Adds a sub layer to render point features.
|
||||
/// </summary>
|
||||
/// <param name="assignedSubLayerName">Assigned sub layer name.</param>
|
||||
/// <param name="dataLayerNameInService">Data layer name in service.</param>
|
||||
void AddPointFeatureSubLayer(string assignedSubLayerName, string dataLayerNameInService);
|
||||
|
||||
/// <summary>
|
||||
/// Adds feature sub layer for rendering using a custom pipeline.
|
||||
/// Custom Feature Sub Layer should be used with custom modifiers to leverage the layer data or render it using a non-standard pipeline.
|
||||
/// </summary>
|
||||
/// <param name="assignedSubLayerName">Assigned sub layer name.</param>
|
||||
/// <param name="dataLayerNameInService">Data layer name in service.</param>
|
||||
void AddCustomFeatureSubLayer(string assignedSubLayerName, string dataLayerNameInService);
|
||||
|
||||
IEnumerable<VectorSubLayerProperties> GetAllFeatureSubLayers();
|
||||
|
||||
IEnumerable<VectorSubLayerProperties> GetAllPolygonFeatureSubLayers();
|
||||
|
||||
IEnumerable<VectorSubLayerProperties> GetAllLineFeatureSubLayers();
|
||||
|
||||
IEnumerable<VectorSubLayerProperties> GetAllPointFeatureSubLayers();
|
||||
|
||||
IEnumerable<VectorSubLayerProperties> GetFeatureSubLayerByQuery(Func<VectorSubLayerProperties, bool> query);
|
||||
|
||||
VectorSubLayerProperties GetFeatureSubLayerAtIndex(int i);
|
||||
|
||||
VectorSubLayerProperties FindFeatureSubLayerWithName(string featureLayerName);
|
||||
|
||||
void RemoveFeatureSubLayerWithName(string featureLayerName);
|
||||
|
||||
void RemoveFeatureSubLayer(VectorSubLayerProperties layer);
|
||||
|
||||
// POI LAYER OPERATIONS
|
||||
|
||||
void AddPointsOfInterestSubLayer(PrefabItemOptions poiLayerProperties);
|
||||
|
||||
IEnumerable<PrefabItemOptions> GetAllPointsOfInterestSubLayers();
|
||||
|
||||
PrefabItemOptions GetPointsOfInterestSubLayerAtIndex(int i);
|
||||
|
||||
IEnumerable<PrefabItemOptions> GetPointsOfInterestSubLayerByQuery(Func<PrefabItemOptions, bool> query);
|
||||
|
||||
PrefabItemOptions FindPointsofInterestSubLayerWithName(string poiLayerName);
|
||||
|
||||
void RemovePointsOfInterestSubLayerWithName(string poiLayerName);
|
||||
|
||||
void RemovePointsOfInterestSubLayer(PrefabItemOptions layer);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Poi Api Methods
|
||||
|
||||
/// <summary>
|
||||
/// Places a prefab at the specified LatLon on the Map.
|
||||
/// </summary>
|
||||
/// <param name="prefab"> A Game Object Prefab.</param>
|
||||
/// <param name="LatLon">A Vector2d(Latitude Longitude) object</param>
|
||||
void SpawnPrefabAtGeoLocation(GameObject prefab,
|
||||
Vector2d LatLon,
|
||||
Action<List<GameObject>> callback = null,
|
||||
bool scaleDownWithWorld = true,
|
||||
string locationItemName = "New Location");
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Places a prefab at all locations specified by the LatLon array.
|
||||
/// </summary>
|
||||
/// <param name="prefab"> A Game Object Prefab.</param>
|
||||
/// <param name="LatLon">A Vector2d(Latitude Longitude) object</param>
|
||||
void SpawnPrefabAtGeoLocation(GameObject prefab,
|
||||
Vector2d[] LatLon,
|
||||
Action<List<GameObject>> callback = null,
|
||||
bool scaleDownWithWorld = true,
|
||||
string locationItemName = "New Location");
|
||||
|
||||
/// <summary>
|
||||
/// Places the prefab for supplied categories.
|
||||
/// </summary>
|
||||
/// <param name="prefab">GameObject Prefab</param>
|
||||
/// <param name="categories"><see cref="LocationPrefabCategories"/> For more than one category separate them by pipe
|
||||
/// (eg: LocationPrefabCategories.Food | LocationPrefabCategories.Nightlife)</param>
|
||||
/// <param name="density">Density controls the number of POIs on the map.(Integer value between 1 and 30)</param>
|
||||
/// <param name="locationItemName">Name of this location prefab item for future reference</param>
|
||||
/// <param name="scaleDownWithWorld">Should the prefab scale up/down along with the map game object?</param>
|
||||
void SpawnPrefabByCategory(GameObject prefab,
|
||||
LocationPrefabCategories categories = LocationPrefabCategories.AnyCategory,
|
||||
int density = 30, Action<List<GameObject>> callback = null,
|
||||
bool scaleDownWithWorld = true,
|
||||
string locationItemName = "New Location");
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Places the prefab at POI locations if its name contains the supplied string
|
||||
/// <param name="prefab">GameObject Prefab</param>
|
||||
/// <param name="nameString">This is the string that will be checked against the POI name to see if is contained in it, and ony those POIs will be spawned</param>
|
||||
/// <param name="density">Density (Integer value between 1 and 30)</param>
|
||||
/// <param name="locationItemName">Name of this location prefab item for future reference</param>
|
||||
/// <param name="scaleDownWithWorld">Should the prefab scale up/down along with the map game object?</param>
|
||||
/// </summary>
|
||||
void SpawnPrefabByName(GameObject prefab,
|
||||
string nameString,
|
||||
int density = 30,
|
||||
Action<List<GameObject>> callback = null,
|
||||
bool scaleDownWithWorld = true,
|
||||
string locationItemName = "New Location");
|
||||
#endregion
|
||||
}
|
||||
|
||||
// TODO: Move interfaces into individual files.
|
||||
|
||||
public interface ISubLayerPolygonGeometryOptions
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public interface ISubLayerFiltering
|
||||
{
|
||||
ILayerFilter AddStringFilterContains(string key, string property);
|
||||
ILayerFilter AddNumericFilterEquals(string key, float value);
|
||||
ILayerFilter AddNumericFilterLessThan(string key, float value);
|
||||
ILayerFilter AddNumericFilterGreaterThan(string key, float value);
|
||||
ILayerFilter AddNumericFilterInRange(string key, float min, float max);
|
||||
|
||||
ILayerFilter GetFilter(int index);
|
||||
|
||||
void RemoveFilter(int index);
|
||||
void RemoveFilter(LayerFilter filter);
|
||||
void RemoveFilter(ILayerFilter filter);
|
||||
void RemoveAllFilters();
|
||||
|
||||
IEnumerable<ILayerFilter> GetAllFilters();
|
||||
IEnumerable<ILayerFilter> GetFiltersByQuery(System.Func<ILayerFilter, bool> query);
|
||||
|
||||
LayerFilterCombinerOperationType GetFilterCombinerType();
|
||||
|
||||
void SetFilterCombinerType(LayerFilterCombinerOperationType layerFilterCombinerOperationType);
|
||||
}
|
||||
|
||||
public interface ILayerFilter
|
||||
{
|
||||
bool FilterKeyContains(string key);
|
||||
bool FilterKeyMatchesExact(string key);
|
||||
bool FilterUsesOperationType(LayerFilterOperationType layerFilterOperationType);
|
||||
bool FilterPropertyContains(string property);
|
||||
bool FilterPropertyMatchesExact(string property);
|
||||
bool FilterNumberValueEquals(float value);
|
||||
bool FilterNumberValueIsGreaterThan(float value);
|
||||
bool FilterNumberValueIsLessThan(float value);
|
||||
bool FilterIsInRangeValueContains(float value);
|
||||
|
||||
string GetKey { get; }
|
||||
LayerFilterOperationType GetFilterOperationType { get; }
|
||||
|
||||
string GetPropertyValue { get; }
|
||||
float GetNumberValue { get; }
|
||||
|
||||
float GetMinValue { get; }
|
||||
float GetMaxValue { get; }
|
||||
|
||||
void SetStringContains(string key, string property);
|
||||
void SetNumberIsEqual(string key, float value);
|
||||
void SetNumberIsLessThan(string key, float value);
|
||||
void SetNumberIsGreaterThan(string key, float value);
|
||||
void SetNumberIsInRange(string key, float min, float max);
|
||||
|
||||
}
|
||||
|
||||
public interface IVectorSubLayer
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets `Filters` data from the feature.
|
||||
/// </summary>
|
||||
ISubLayerFiltering Filtering { get; }
|
||||
/// <summary>
|
||||
/// Gets `Modeling` data from the feature.
|
||||
/// </summary>
|
||||
ISubLayerModeling Modeling { get; }
|
||||
/// <summary>
|
||||
/// Gets `Texturing` data from the feature.
|
||||
/// </summary>
|
||||
ISubLayerTexturing Texturing { get; }
|
||||
/// <summary>
|
||||
/// Gets `Behavior Modifiers` data from the feature.
|
||||
/// </summary>
|
||||
ISubLayerBehaviorModifiers BehaviorModifiers { get; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
13
Assets/Mapbox SDK/Mapbox/Unity/SourceLayers/ILayer.cs.meta
Normal file
13
Assets/Mapbox SDK/Mapbox/Unity/SourceLayers/ILayer.cs.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5f9eea74368704d888e4636d6229f30b
|
||||
timeCreated: 1519860268
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Mapbox.Unity.MeshGeneration.Modifiers;
|
||||
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
public interface ISubLayerBehaviorModifiers
|
||||
{
|
||||
void IsBuildingIdsUnique(bool isUniqueIds);
|
||||
|
||||
void AddMeshModifier(MeshModifier modifier);
|
||||
void AddMeshModifier(List<MeshModifier> modifiers);
|
||||
List<MeshModifier> GetMeshModifier(Func<MeshModifier, bool> act);
|
||||
void RemoveMeshModifier(MeshModifier modifier);
|
||||
|
||||
void AddGameObjectModifier(GameObjectModifier modifier);
|
||||
void AddGameObjectModifier(List<GameObjectModifier> modifiers);
|
||||
List<GameObjectModifier> GetGameObjectModifier(Func<GameObjectModifier, bool> act);
|
||||
void RemoveGameObjectModifier(GameObjectModifier modifier);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1e87244935b842089e18d5a142aab6f6
|
||||
timeCreated: 1538422739
|
||||
@@ -0,0 +1,13 @@
|
||||
using Mapbox.Unity.Map;
|
||||
|
||||
namespace Mapbox.Unity.SourceLayers
|
||||
{
|
||||
public interface ISubLayerColliderOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Enable/Disable feature colliders and sets the type of colliders to use.
|
||||
/// </summary>
|
||||
/// <param name="colliderType">Type of the collider to use on features.</param>
|
||||
void SetFeatureCollider(ColliderType colliderType);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 61f3c217145242289818236c5e1453e1
|
||||
timeCreated: 1538173678
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using UnityEngine;
|
||||
|
||||
public interface ISubLayerColorStyle : ISubLayerStyle
|
||||
{
|
||||
Color FeatureColor { get; set; }
|
||||
void SetAsStyle(Color featureColor);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 997854840cbc44433b7bb5dce1c2da46
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
public interface ISubLayerCoreOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Change the primtive type of the feature which will be used to decide
|
||||
/// what type of mesh operations features will require.
|
||||
/// In example, roads are generally visualized as lines and buildings are
|
||||
/// generally visualized as polygons.
|
||||
/// </summary>
|
||||
/// <param name="type">Primitive type of the featues in the layer.</param>
|
||||
void SetPrimitiveType(VectorPrimitiveType type);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 23f54a8816004e0a80a6eddb751c77a8
|
||||
timeCreated: 1538173695
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
public interface ISubLayerCustomStyle
|
||||
{
|
||||
UvMapType TexturingType { get; set; }
|
||||
ISubLayerCustomStyleTiled Tiled { get; }
|
||||
ISubLayerCustomStyleAtlas TextureAtlas { get; }
|
||||
ISubLayerCustomStyleAtlasWithColorPallete TextureAtlasWithColorPallete { get; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aa05a4fc1ec3d450baeff5e3c4538fe3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using UnityEngine;
|
||||
using Mapbox.Unity.MeshGeneration.Data;
|
||||
|
||||
public interface ISubLayerCustomStyleAtlas : ISubLayerCustomStyleOptions, ISubLayerStyle
|
||||
{
|
||||
AtlasInfo UvAtlas { get; set; }
|
||||
void SetAsStyle(Material TopMaterial, Material SideMaterial, AtlasInfo uvAtlas);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 91bb7738d3ba44f27bad10b8c1d22bcd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using UnityEngine;
|
||||
using Mapbox.Unity.MeshGeneration.Data;
|
||||
|
||||
public interface ISubLayerCustomStyleAtlasWithColorPallete : ISubLayerCustomStyleOptions, ISubLayerStyle
|
||||
{
|
||||
ScriptablePalette ColorPalette { get; set; }
|
||||
void SetAsStyle(Material TopMaterial, Material SideMaterial, AtlasInfo uvAtlas, ScriptablePalette palette);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f6fa1fbd7ea4a4f7d87db12ffcc87f7e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using UnityEngine;
|
||||
|
||||
public interface ISubLayerCustomStyleOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the top material.
|
||||
/// </summary>
|
||||
/// <value>The top material.</value>
|
||||
Material TopMaterial { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the side material.
|
||||
/// </summary>
|
||||
/// <value>The side material.</value>
|
||||
Material SideMaterial { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fd328d461e03643129348584d9d8e6ce
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using UnityEngine;
|
||||
|
||||
public interface ISubLayerCustomStyleTiled : ISubLayerCustomStyleOptions, ISubLayerStyle
|
||||
{
|
||||
void SetMaterials(Material TopMaterial, Material SideMaterial);
|
||||
void SetAsStyle(Material TopMaterial, Material SideMaterial = null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dec23fe931b534e3aad750e71921d9f7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
public interface ISubLayerDarkStyle : ISubLayerStyle
|
||||
{
|
||||
float Opacity { get; set; }
|
||||
void SetAsStyle(float opacity);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 84bf507c20215450a968d9bbed1b014b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,85 @@
|
||||
using Mapbox.Unity.Map;
|
||||
|
||||
namespace Mapbox.Unity.SourceLayers
|
||||
{
|
||||
public interface ISubLayerExtrusionOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Disable mesh extrusion for the features in this layer.
|
||||
/// </summary>
|
||||
void DisableExtrusion();
|
||||
|
||||
/// <summary>
|
||||
/// Sets the height value to be used for Absolute Height extrusion type.
|
||||
/// Same field is used for the maximum height of Range Extrusion type so beware
|
||||
/// of possible side effects.
|
||||
/// </summary>
|
||||
/// <param name="absoluteHeight">Fixed height value for all features in the layer.</param>
|
||||
void SetAbsoluteHeight(float absoluteHeight);
|
||||
|
||||
/// <summary>
|
||||
/// Change the minimum and maximum height values used for Range Height option.
|
||||
/// Maximum height is also used for Absolute Height option so beware of possible side
|
||||
/// effects.
|
||||
/// </summary>
|
||||
/// <param name="minHeight">Lower bound to be used for extrusion</param>
|
||||
/// <param name="maxHeight">Top bound to be used for extrusion</param>
|
||||
void SetHeightRange(float minHeight, float maxHeight);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the extrusion multiplier which will be used only in the Y axis (height).
|
||||
/// </summary>
|
||||
/// <param name="multiplier">Multiplier value.</param>
|
||||
void SetExtrusionMultiplier(float multiplier);
|
||||
|
||||
/// <summary>
|
||||
/// Changes extrusion type to "Absolute height" and extrudes all features by
|
||||
/// the given fixed value.
|
||||
/// </summary>
|
||||
/// <param name="extrusionGeometryType">Option to create top and side polygons after extrusion.</param>
|
||||
/// <param name="height">Extrusion value</param>
|
||||
/// <param name="extrusionScaleFactor">Height multiplier</param>
|
||||
void EnableAbsoluteExtrusion(ExtrusionGeometryType extrusionGeometryType, float height, float extrusionScaleFactor = 1);
|
||||
|
||||
/// <summary>
|
||||
/// Changes extrusion type to "Property" and extrudes all features by
|
||||
/// the choosen property's value.
|
||||
/// </summary>
|
||||
/// <param name="extrusionGeometryType">Option to create top and side polygons after extrusion.</param>
|
||||
/// <param name="propertyName">Name of the property to use for extrusion</param>
|
||||
/// <param name="extrusionScaleFactor">Height multiplier</param>
|
||||
void EnablePropertyExtrusion(ExtrusionGeometryType extrusionGeometryType, string propertyName = "height", float extrusionScaleFactor = 1);
|
||||
|
||||
/// <summary>
|
||||
/// Changes extrusion type to "Minimum Height" and extrudes all features by
|
||||
/// the choosen property's value such that all vertices (roof) will be
|
||||
/// flat at the lowest vertex elevation (after terrain elevation taken into account).
|
||||
/// </summary>
|
||||
/// <param name="extrusionGeometryType">Option to create top and side polygons after extrusion.</param>
|
||||
/// <param name="propertyName">Name of the property to use for extrusion</param>
|
||||
/// <param name="extrusionScaleFactor">Height multiplier</param>
|
||||
void EnableMinExtrusion(ExtrusionGeometryType extrusionGeometryType, string propertyName = "height", float extrusionScaleFactor = 1);
|
||||
|
||||
/// <summary>
|
||||
/// Changes extrusion type to "Range Height" and extrudes all features by
|
||||
/// the choosen property's value such that all vertices (roof) will be
|
||||
/// flat at the highest vertex elevation (after terrain elevation taken into account).
|
||||
/// </summary>
|
||||
/// <param name="extrusionGeometryType">Option to create top and side polygons after extrusion.</param>
|
||||
/// <param name="propertyName">Name of the property to use for extrusion</param>
|
||||
/// <param name="extrusionScaleFactor">Height multiplier</param>
|
||||
void EnableMaxExtrusion(ExtrusionGeometryType extrusionGeometryType, string propertyName = "height", float extrusionScaleFactor = 1);
|
||||
|
||||
/// /// <summary>
|
||||
/// Changes extrusion type to "Minimum Height" and extrudes all features by
|
||||
/// the choosen property's value such that they'll be in provided range.
|
||||
/// Lower values will be increase to Minimum Height and higher values will
|
||||
/// be lowered to Maximum height.
|
||||
/// </summary>
|
||||
/// <param name="extrusionGeometryType">Option to create top and side polygons after extrusion.</param>
|
||||
/// <param name="minHeight">Lower bound to be used for extrusion</param>
|
||||
/// <param name="maxHeight">Top bound to be used for extrusion</param>
|
||||
/// <param name="extrusionScaleFactor">Height multiplier</param>
|
||||
void EnableRangeExtrusion(ExtrusionGeometryType extrusionGeometryType, float minHeight, float maxHeight, float extrusionScaleFactor = 1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 585a84b1db824dd4840e111be54f229e
|
||||
timeCreated: 1538173687
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
public interface ISubLayerFantasyStyle : ISubLayerStyle
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 682cc02fda6d5468cbf9168c6eadfc2e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
public interface ISubLayerLightStyle : ISubLayerStyle
|
||||
{
|
||||
float Opacity { get; set; }
|
||||
void SetAsStyle(float opacity);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ad0c9ea89e78e425491adfc13c5cc0c0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace Mapbox.Unity.SourceLayers
|
||||
{
|
||||
public interface ISubLayerLineGeometryOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets the width of the mesh generated for line features.
|
||||
/// </summary>
|
||||
/// <param name="width">Width of the mesh generated for line features.</param>
|
||||
void SetLineWidth(float width);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 80871125bf304f71aa5f43d2aa183376
|
||||
timeCreated: 1538173669
|
||||
@@ -0,0 +1,26 @@
|
||||
using Mapbox.Unity.Map;
|
||||
|
||||
namespace Mapbox.Unity.SourceLayers
|
||||
{
|
||||
public interface ISubLayerModeling
|
||||
{
|
||||
ISubLayerCoreOptions CoreOptions { get; }
|
||||
ISubLayerExtrusionOptions ExtrusionOptions { get; }
|
||||
ISubLayerColliderOptions ColliderOptions { get; }
|
||||
ISubLayerLineGeometryOptions LineOptions { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Enable terrain snapping for features which sets vertices to terrain
|
||||
/// elevation before extrusion.
|
||||
/// </summary>
|
||||
/// <param name="isEnabled">Enabled terrain snapping</param>
|
||||
void EnableSnapingTerrain(bool isEnabled);
|
||||
|
||||
/// <summary>
|
||||
/// Enable combining individual features meshes into one to minimize gameobject
|
||||
/// count and draw calls.
|
||||
/// </summary>
|
||||
/// <param name="isEnabled"></param>
|
||||
void EnableCombiningMeshes(bool isEnabled);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 73b3b85ffdb64bb8a01ccb8755fae669
|
||||
timeCreated: 1538173657
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
public interface ISubLayerRealisticStyle : ISubLayerStyle
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ea19562da51454ef893a64ebaa44f1da
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
public interface ISubLayerSimpleStyle : ISubLayerStyle
|
||||
{
|
||||
SamplePalettes PaletteType { get; set; }
|
||||
void SetAsStyle(SamplePalettes palette);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bdd2a8bddc6c14990b71aeaa10353c2b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
public interface ISubLayerStyle
|
||||
{
|
||||
void SetAsStyle();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f1c42abc9a20244c8b46c1cbb234eacf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,30 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
public interface ISubLayerTexturing
|
||||
{
|
||||
ISubLayerDarkStyle DarkStyle { get; }
|
||||
ISubLayerLightStyle LightStyle { get; }
|
||||
ISubLayerColorStyle ColorStyle { get; }
|
||||
|
||||
ISubLayerRealisticStyle RealisticStyle { get; }
|
||||
ISubLayerFantasyStyle FantasyStyle { get; }
|
||||
ISubLayerSimpleStyle SimpleStyle { get; }
|
||||
|
||||
ISubLayerCustomStyle CustomStyle { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Sets the type of the style.
|
||||
/// </summary>
|
||||
/// <param name="styleType">Style type.</param>
|
||||
void SetStyleType(StyleTypes styleType);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type of style used in the layer.
|
||||
/// </summary>
|
||||
/// <returns>The style type.</returns>
|
||||
StyleTypes GetStyleType();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 69bc09e420e0949999f2fbaf03292937
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
95
Assets/Mapbox SDK/Mapbox/Unity/SourceLayers/ITerrainLayer.cs
Normal file
95
Assets/Mapbox SDK/Mapbox/Unity/SourceLayers/ITerrainLayer.cs
Normal file
@@ -0,0 +1,95 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
public interface ITerrainLayer : ILayer
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the `Data Source` for the `TERRAIN` section.
|
||||
/// </summary>
|
||||
ElevationSourceType LayerSource { get; }
|
||||
/// <summary>
|
||||
/// Gets the `Elevation Layer Type` for the `TERRAIN` section.
|
||||
/// </summary>
|
||||
ElevationLayerType ElevationType { get; set; }
|
||||
/// <summary>
|
||||
/// Gets the `Exaggeration Factor` for the `TERRAIN` section.
|
||||
/// </summary>
|
||||
float ExaggerationFactor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Sets the Data Source for `TERRAIN`. By default this is set to
|
||||
/// `Mapbox Terrain`. Currenly, only terrain-rgb is supported.
|
||||
/// Use <paramref name="terrainSource"/> = `None`, to disable the terrain.
|
||||
/// </summary>
|
||||
/// <param name="terrainSource">`Data Source` for `TERRAIN`</param>
|
||||
void SetLayerSource(ElevationSourceType terrainSource = ElevationSourceType.MapboxTerrain);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the `Elevation Layer Type` which is the main strategy for terrain
|
||||
/// mesh generation. `Flat Terrain` doesn't pull data from servers, it
|
||||
/// uses a quad as the terrain. </summary>
|
||||
/// <param name="elevationType">Type of the elevation. Can be set to `Terrain with Elevation`,
|
||||
/// `Flat Terrain`, `Globe`, or `Low Polygon Terrain`. Note: low poly doesn't
|
||||
/// improve performance.</param>
|
||||
void SetElevationType(ElevationLayerType elevationType);
|
||||
|
||||
/// <summary>
|
||||
/// Enables or disables the `Add Collider` settings for adding a collider
|
||||
/// to the terrain. The collider type is a mesh collider.
|
||||
/// </summary>
|
||||
/// <param name="enable">Boolean for toggling `Add Collider`. </param>
|
||||
void EnableCollider(bool enable);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the `Exaggeration Factor` for the terrain. This acts as a multiplier
|
||||
/// for elevation. Use this setting to better highlight elevation in your scene.
|
||||
/// Each elevation point will be multiplied by the float value.
|
||||
/// </summary>
|
||||
/// <param name="factor">Elevation multiplier for `Exaggeration Factor` settings. </param>
|
||||
void SetExaggerationFactor(float factor);
|
||||
|
||||
/// <summary>
|
||||
/// Enables the settings for `Show Sidewalls`.
|
||||
/// </summary>
|
||||
/// <param name="wallHeight">Wall height.</param>
|
||||
/// <param name="wallMaterial">Wall material.</param>
|
||||
void EnableSideWalls(float wallHeight, Material wallMaterial);
|
||||
|
||||
/// <summary>
|
||||
/// Disables the settings for `Show Sidewalls`.
|
||||
/// </summary>
|
||||
void DisableSideWalls();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Adds the terrain mesh GameObject to a Unity layer.
|
||||
/// </summary>
|
||||
/// <param name="layerId">Layer identifier. You may need to add the layer in
|
||||
/// the Tags and Layers manager.</param>
|
||||
void AddToUnityLayer(int layerId);
|
||||
|
||||
/// <summary>
|
||||
/// Removes the terrain GameObject from a Unity layer.
|
||||
/// </summary>
|
||||
/// <param name="layerId">Layer identifier.</param>
|
||||
void RemoveFromUnityLayer(int layerId);
|
||||
|
||||
/// <summary>
|
||||
/// Change the `TERRAIN` layer settings.
|
||||
/// </summary>
|
||||
/// <param name="dataSource">The `Data Source` for the terrain.</param>
|
||||
/// <param name="elevationType">`Elevation Layer Type` setting to define elevation strategy.</param>
|
||||
/// <param name="enableCollider">Enables or disables `Use Collider` settings for a mesh collider on the terrain.</param>
|
||||
/// <param name="factor">`Exaggertion Factor` for a multiplier of the height data.</param>
|
||||
/// <param name="layerId">`Add to Unity Layer` settings which adds terrrain to a layer.</param>
|
||||
void SetProperties(ElevationSourceType dataSource = ElevationSourceType.MapboxTerrain, ElevationLayerType elevationType = ElevationLayerType.TerrainWithElevation, bool enableCollider = false, float factor = 1, int layerId = 0);
|
||||
}
|
||||
|
||||
|
||||
public interface IGlobeTerrainLayer : ITerrainLayer
|
||||
{
|
||||
float EarthRadius { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 187ce6c4b50f5417890e85afdfe403c4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
234
Assets/Mapbox SDK/Mapbox/Unity/SourceLayers/ImageryLayer.cs
Normal file
234
Assets/Mapbox SDK/Mapbox/Unity/SourceLayers/ImageryLayer.cs
Normal file
@@ -0,0 +1,234 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using Mapbox.Unity.MeshGeneration.Factories;
|
||||
using Mapbox.Unity.Utilities;
|
||||
|
||||
[Serializable]
|
||||
public class ImageryLayer : AbstractLayer, IImageryLayer
|
||||
{
|
||||
[SerializeField]
|
||||
ImageryLayerProperties _layerProperty = new ImageryLayerProperties();
|
||||
|
||||
[NodeEditorElement("Image Layer")]
|
||||
public ImageryLayerProperties LayerProperty
|
||||
{
|
||||
get
|
||||
{
|
||||
return _layerProperty;
|
||||
}
|
||||
set
|
||||
{
|
||||
_layerProperty = value;
|
||||
}
|
||||
}
|
||||
public MapLayerType LayerType
|
||||
{
|
||||
get
|
||||
{
|
||||
return MapLayerType.Imagery;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsLayerActive
|
||||
{
|
||||
get
|
||||
{
|
||||
return (_layerProperty.sourceType != ImagerySourceType.None);
|
||||
}
|
||||
}
|
||||
|
||||
public string LayerSourceId
|
||||
{
|
||||
get
|
||||
{
|
||||
return _layerProperty.sourceOptions.Id;
|
||||
}
|
||||
internal set
|
||||
{
|
||||
if (value != _layerProperty.sourceOptions.Id)
|
||||
{
|
||||
_layerProperty.sourceOptions.Id = value;
|
||||
_layerProperty.HasChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ImagerySourceType LayerSource
|
||||
{
|
||||
get
|
||||
{
|
||||
return _layerProperty.sourceType;
|
||||
}
|
||||
}
|
||||
|
||||
public ImageryLayer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ImageryLayer(ImageryLayerProperties properties)
|
||||
{
|
||||
_layerProperty = properties;
|
||||
}
|
||||
|
||||
|
||||
public void SetLayerSource(string imageSource)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(imageSource))
|
||||
{
|
||||
_layerProperty.sourceType = ImagerySourceType.Custom;
|
||||
_layerProperty.sourceOptions.Id = imageSource;
|
||||
}
|
||||
else
|
||||
{
|
||||
_layerProperty.sourceType = ImagerySourceType.None;
|
||||
Debug.LogWarning("Empty source - turning off imagery. ");
|
||||
}
|
||||
_layerProperty.HasChanged = true;
|
||||
}
|
||||
|
||||
public void SetRasterOptions(ImageryRasterOptions rasterOptions)
|
||||
{
|
||||
_layerProperty.rasterOptions = rasterOptions;
|
||||
_layerProperty.HasChanged = true;
|
||||
}
|
||||
|
||||
public void Initialize(LayerProperties properties)
|
||||
{
|
||||
_layerProperty = (ImageryLayerProperties)properties;
|
||||
Initialize();
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
if (_layerProperty.sourceType != ImagerySourceType.Custom && _layerProperty.sourceType != ImagerySourceType.None)
|
||||
{
|
||||
_layerProperty.sourceOptions.layerSource = MapboxDefaultImagery.GetParameters(_layerProperty.sourceType);
|
||||
}
|
||||
_imageFactory = ScriptableObject.CreateInstance<MapImageFactory>();
|
||||
_imageFactory.SetOptions(_layerProperty);
|
||||
_layerProperty.PropertyHasChanged += RedrawLayer;
|
||||
_layerProperty.rasterOptions.PropertyHasChanged += (property, e) =>
|
||||
{
|
||||
NotifyUpdateLayer(_imageFactory, property as MapboxDataProperty, false);
|
||||
};
|
||||
}
|
||||
|
||||
public void RedrawLayer(object sender, System.EventArgs e)
|
||||
{
|
||||
Factory.SetOptions(_layerProperty);
|
||||
NotifyUpdateLayer(_imageFactory, sender as MapboxDataProperty, false);
|
||||
}
|
||||
|
||||
public void Remove()
|
||||
{
|
||||
_layerProperty = new ImageryLayerProperties
|
||||
{
|
||||
sourceType = ImagerySourceType.None
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(LayerProperties properties)
|
||||
{
|
||||
Initialize(properties);
|
||||
}
|
||||
|
||||
private MapImageFactory _imageFactory;
|
||||
public MapImageFactory Factory
|
||||
{
|
||||
get
|
||||
{
|
||||
return _imageFactory;
|
||||
}
|
||||
}
|
||||
|
||||
#region API Methods
|
||||
|
||||
/// <summary>
|
||||
/// Sets the data source for the image factory.
|
||||
/// </summary>
|
||||
/// <param name="imageSource"></param>
|
||||
public virtual void SetLayerSource(ImagerySourceType imageSource)
|
||||
{
|
||||
if (imageSource != ImagerySourceType.Custom && imageSource != ImagerySourceType.None)
|
||||
{
|
||||
_layerProperty.sourceType = imageSource;
|
||||
_layerProperty.sourceOptions.layerSource = MapboxDefaultImagery.GetParameters(imageSource);
|
||||
_layerProperty.HasChanged = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("Invalid style - trying to set " + imageSource.ToString() + " as default style!");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enables high quality images for selected image factory source.
|
||||
/// </summary>
|
||||
/// <param name="useRetina"></param>
|
||||
public virtual void UseRetina(bool useRetina)
|
||||
{
|
||||
if (_layerProperty.rasterOptions.useRetina != useRetina)
|
||||
{
|
||||
_layerProperty.rasterOptions.useRetina = useRetina;
|
||||
_layerProperty.rasterOptions.HasChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enable Texture2D compression for image factory outputs.
|
||||
/// </summary>
|
||||
/// <param name="useCompression"></param>
|
||||
public virtual void UseCompression(bool useCompression)
|
||||
{
|
||||
if (_layerProperty.rasterOptions.useCompression != useCompression)
|
||||
{
|
||||
_layerProperty.rasterOptions.useCompression = useCompression;
|
||||
_layerProperty.rasterOptions.HasChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enable Texture2D MipMap option for image factory outputs.
|
||||
/// </summary>
|
||||
/// <param name="useMipMap"></param>
|
||||
public virtual void UseMipMap(bool useMipMap)
|
||||
{
|
||||
if (_layerProperty.rasterOptions.useMipMap != useMipMap)
|
||||
{
|
||||
_layerProperty.rasterOptions.useMipMap = useMipMap;
|
||||
_layerProperty.rasterOptions.HasChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Change image layer settings.
|
||||
/// </summary>
|
||||
/// <param name="imageSource">Data source for the image provider.</param>
|
||||
/// <param name="useRetina">Enable/Disable high quality imagery.</param>
|
||||
/// <param name="useCompression">Enable/Disable Unity3d Texture2d image compression.</param>
|
||||
/// <param name="useMipMap">Enable/Disable Unity3d Texture2d image mipmapping.</param>
|
||||
public virtual void SetProperties(ImagerySourceType imageSource, bool useRetina, bool useCompression, bool useMipMap)
|
||||
{
|
||||
if (imageSource != ImagerySourceType.Custom && imageSource != ImagerySourceType.None)
|
||||
{
|
||||
_layerProperty.sourceType = imageSource;
|
||||
_layerProperty.sourceOptions.layerSource = MapboxDefaultImagery.GetParameters(imageSource);
|
||||
_layerProperty.HasChanged = true;
|
||||
}
|
||||
|
||||
if (_layerProperty.rasterOptions.useRetina != useRetina ||
|
||||
_layerProperty.rasterOptions.useCompression != useCompression ||
|
||||
_layerProperty.rasterOptions.useMipMap != useMipMap)
|
||||
{
|
||||
_layerProperty.rasterOptions.useRetina = useRetina;
|
||||
_layerProperty.rasterOptions.useCompression = useCompression;
|
||||
_layerProperty.rasterOptions.useMipMap = useMipMap;
|
||||
_layerProperty.rasterOptions.HasChanged = true;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e27f3b90b51364893ba4077dae9a6f83
|
||||
timeCreated: 1519860268
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,29 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using System;
|
||||
|
||||
public static class MapboxDefaultElevation
|
||||
{
|
||||
public static Style GetParameters(ElevationSourceType defaultElevation)
|
||||
{
|
||||
Style defaultStyle = new Style();
|
||||
switch (defaultElevation)
|
||||
{
|
||||
case ElevationSourceType.MapboxTerrain:
|
||||
defaultStyle = new Style
|
||||
{
|
||||
Id = "mapbox.terrain-rgb",
|
||||
Name = "Mapbox Terrain"
|
||||
};
|
||||
|
||||
break;
|
||||
case ElevationSourceType.Custom:
|
||||
throw new Exception("Invalid type : Custom");
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return defaultStyle;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2e4a090c1e7164452aa2e5e568bcf1a3
|
||||
timeCreated: 1520911901
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,71 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using System;
|
||||
using Mapbox.Unity.MeshGeneration.Factories;
|
||||
public static class MapboxDefaultImagery
|
||||
{
|
||||
public static Style GetParameters(ImagerySourceType defaultImagery)
|
||||
{
|
||||
Style defaultStyle = new Style();
|
||||
switch (defaultImagery)
|
||||
{
|
||||
case ImagerySourceType.MapboxStreets:
|
||||
defaultStyle = new Style
|
||||
{
|
||||
Id = "mapbox://styles/mapbox/streets-v10",
|
||||
Name = "Streets"
|
||||
};
|
||||
|
||||
break;
|
||||
case ImagerySourceType.MapboxOutdoors:
|
||||
defaultStyle = new Style
|
||||
{
|
||||
Id = "mapbox://styles/mapbox/outdoors-v10",
|
||||
Name = "Streets"
|
||||
};
|
||||
|
||||
break;
|
||||
case ImagerySourceType.MapboxDark:
|
||||
defaultStyle = new Style
|
||||
{
|
||||
Id = "mapbox://styles/mapbox/dark-v9",
|
||||
Name = "Dark"
|
||||
};
|
||||
|
||||
break;
|
||||
case ImagerySourceType.MapboxLight:
|
||||
defaultStyle = new Style
|
||||
{
|
||||
Id = "mapbox://styles/mapbox/light-v9",
|
||||
Name = "Light"
|
||||
};
|
||||
|
||||
break;
|
||||
case ImagerySourceType.MapboxSatellite:
|
||||
defaultStyle = new Style
|
||||
{
|
||||
Id = "mapbox.satellite",
|
||||
Name = "Satellite"
|
||||
};
|
||||
|
||||
break;
|
||||
case ImagerySourceType.MapboxSatelliteStreet:
|
||||
defaultStyle = new Style
|
||||
{
|
||||
Id = "mapbox://styles/mapbox/satellite-streets-v10",
|
||||
Name = "Satellite Streets"
|
||||
};
|
||||
|
||||
break;
|
||||
case ImagerySourceType.Custom:
|
||||
throw new Exception("Invalid type : Custom");
|
||||
case ImagerySourceType.None:
|
||||
throw new Exception("Invalid type : None");
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return defaultStyle;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2ae5c1afa3223459b8343ea6c6d580a2
|
||||
timeCreated: 1519860268
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,34 @@
|
||||
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using System.IO;
|
||||
|
||||
/// <summary>
|
||||
/// MapboxDefaultStyles generates a new GeometryMaterialOptions object based on data contained in a MapFeatureStyleOptions.
|
||||
/// </summary>
|
||||
|
||||
public class StyleAssetPathBundle
|
||||
{
|
||||
public string topMaterialPath;
|
||||
public string sideMaterialPath;
|
||||
public string atlasPath;
|
||||
public string palettePath;
|
||||
|
||||
public StyleAssetPathBundle(string styleName, string path, string samplePaletteName = "")
|
||||
{
|
||||
string topMaterialName = string.Format("{0}{1}", styleName, Constants.StyleAssetNames.TOP_MATERIAL_SUFFIX);
|
||||
string sideMaterialName = string.Format("{0}{1}", styleName, Constants.StyleAssetNames.SIDE_MATERIAL_SUFFIX);
|
||||
string atlasInfoName = string.Format("{0}{1}", styleName, Constants.StyleAssetNames.ALTAS_SUFFIX);
|
||||
string paletteName = (styleName == "Simple") ? samplePaletteName : string.Format("{0}{1}", styleName, Constants.StyleAssetNames.PALETTE_SUFFIX);
|
||||
|
||||
string materialFolderPath = Path.Combine(path, Constants.Path.MAPBOX_STYLES_MATERIAL_FOLDER);
|
||||
string atlasFolderPath = Path.Combine(path, Constants.Path.MAPBOX_STYLES_ATLAS_FOLDER);
|
||||
string paletteFolderPath = Path.Combine(path, Constants.Path.MAPBOX_STYLES_PALETTES_FOLDER);
|
||||
|
||||
topMaterialPath = Path.Combine(materialFolderPath, topMaterialName);
|
||||
sideMaterialPath = Path.Combine(materialFolderPath, sideMaterialName);
|
||||
atlasPath = Path.Combine(atlasFolderPath, atlasInfoName);
|
||||
palettePath = Path.Combine(paletteFolderPath, paletteName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8ff494b8d5c6a455d91a0e5ef54f549e
|
||||
timeCreated: 1524678818
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,37 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using System;
|
||||
|
||||
public static class MapboxDefaultVector
|
||||
{
|
||||
public static Style GetParameters(VectorSourceType defaultElevation)
|
||||
{
|
||||
Style defaultStyle = new Style();
|
||||
switch (defaultElevation)
|
||||
{
|
||||
case VectorSourceType.MapboxStreets:
|
||||
defaultStyle = new Style
|
||||
{
|
||||
Id = "mapbox.mapbox-streets-v7",
|
||||
Name = "Mapbox Streets"
|
||||
};
|
||||
|
||||
break;
|
||||
case VectorSourceType.MapboxStreetsWithBuildingIds:
|
||||
defaultStyle = new Style
|
||||
{
|
||||
Id = "mapbox.3d-buildings,mapbox.mapbox-streets-v7",
|
||||
Name = "Mapbox Streets With Building Ids"
|
||||
};
|
||||
|
||||
break;
|
||||
case VectorSourceType.Custom:
|
||||
throw new Exception("Invalid type : Custom");
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return defaultStyle;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c27882298c0e14c0ea03761c9aac8ecb
|
||||
timeCreated: 1520911901
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,141 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Mapbox.Unity.MeshGeneration.Modifiers;
|
||||
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
public class SubLayerBehaviorModifiers : ISubLayerBehaviorModifiers
|
||||
{
|
||||
// TODO: Remove if not required.
|
||||
VectorSubLayerProperties _subLayerProperties;
|
||||
public SubLayerBehaviorModifiers(VectorSubLayerProperties subLayerProperties)
|
||||
{
|
||||
_subLayerProperties = subLayerProperties;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Certain layers ("Mapbox Streets with Building Ids") contains unique identifiers
|
||||
/// to help mesh generation and feature management. This settings should be
|
||||
/// set to "true" while using these tilesets.
|
||||
/// </summary>
|
||||
/// <param name="isUniqueIds">Is layer using unique building ids</param>
|
||||
public virtual void IsBuildingIdsUnique(bool isUniqueIds)
|
||||
{
|
||||
if (_subLayerProperties.buildingsWithUniqueIds != isUniqueIds)
|
||||
{
|
||||
_subLayerProperties.buildingsWithUniqueIds = isUniqueIds;
|
||||
_subLayerProperties.HasChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the strategy for pivot placement for features.
|
||||
/// </summary>
|
||||
/// <param name="positionTargetType">Strategy for feature pivot point</param>
|
||||
public virtual void SetFeaturePivotStrategy(PositionTargetType positionTargetType)
|
||||
{
|
||||
if (_subLayerProperties.moveFeaturePositionTo != positionTargetType)
|
||||
{
|
||||
_subLayerProperties.moveFeaturePositionTo = positionTargetType;
|
||||
_subLayerProperties.HasChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add game object modifier to the modifiers list.
|
||||
/// </summary>
|
||||
/// <param name="modifier">Game object modifier to add to style</param>
|
||||
public virtual void AddGameObjectModifier(GameObjectModifier modifier)
|
||||
{
|
||||
_subLayerProperties.GoModifiers.Add(modifier);
|
||||
_subLayerProperties.HasChanged = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List of game object modifiers to the modifiers list.
|
||||
/// </summary>
|
||||
/// <param name="modifiers">List of game object modifiers to add to style</param>
|
||||
public virtual void AddGameObjectModifier(List<GameObjectModifier> modifiers)
|
||||
{
|
||||
_subLayerProperties.GoModifiers.AddRange(modifiers);
|
||||
_subLayerProperties.HasChanged = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return game object modifiers from the modifiers list by query
|
||||
/// </summary>
|
||||
/// <param name="function">Query function to test mesh modifiers</param>
|
||||
public virtual List<GameObjectModifier> GetGameObjectModifier(Func<GameObjectModifier, bool> function)
|
||||
{
|
||||
var finalList = new List<GameObjectModifier>();
|
||||
foreach (var goModifier in _subLayerProperties.GoModifiers)
|
||||
{
|
||||
if (function(goModifier))
|
||||
{
|
||||
finalList.Add(goModifier);
|
||||
}
|
||||
}
|
||||
|
||||
return finalList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove game object modifier from the modifiers list
|
||||
/// </summary>
|
||||
/// <param name="modifier">Game object modifier to be removed from style</param>
|
||||
public virtual void RemoveGameObjectModifier(GameObjectModifier modifier)
|
||||
{
|
||||
_subLayerProperties.GoModifiers.Remove(modifier);
|
||||
_subLayerProperties.HasChanged = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add mesh modifier to the modifiers list.
|
||||
/// </summary>
|
||||
/// <param name="modifier">Mesh modifier to add to style</param>
|
||||
public virtual void AddMeshModifier(MeshModifier modifier)
|
||||
{
|
||||
_subLayerProperties.MeshModifiers.Add(modifier);
|
||||
_subLayerProperties.HasChanged = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List of mesh modifiers to the modifiers list.
|
||||
/// </summary>
|
||||
/// <param name="modifiers">List of mesh modifiers to add to style</param>
|
||||
public virtual void AddMeshModifier(List<MeshModifier> modifiers)
|
||||
{
|
||||
_subLayerProperties.MeshModifiers.AddRange(modifiers);
|
||||
_subLayerProperties.HasChanged = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return mesh modifiers from the modifiers list by query
|
||||
/// </summary>
|
||||
/// <param name="function">Query function to test mesh modifiers</param>
|
||||
public virtual List<MeshModifier> GetMeshModifier(Func<MeshModifier, bool> function)
|
||||
{
|
||||
var finalList = new List<MeshModifier>();
|
||||
foreach (var meshModifier in _subLayerProperties.MeshModifiers)
|
||||
{
|
||||
if (function(meshModifier))
|
||||
{
|
||||
finalList.Add(meshModifier);
|
||||
}
|
||||
}
|
||||
|
||||
return finalList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove mesh modifier from the modifiers list
|
||||
/// </summary>
|
||||
/// <param name="modifier">Mesh modifier to be removed from style</param>
|
||||
public virtual void RemoveMeshModifier(MeshModifier modifier)
|
||||
{
|
||||
_subLayerProperties.MeshModifiers.Remove(modifier);
|
||||
_subLayerProperties.HasChanged = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4777224cd8804cc09e27cec98766a375
|
||||
timeCreated: 1538422726
|
||||
@@ -0,0 +1,45 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using UnityEngine;
|
||||
|
||||
public class SubLayerColorStyle : ISubLayerColorStyle
|
||||
{
|
||||
private GeometryMaterialOptions _materialOptions;
|
||||
public SubLayerColorStyle(GeometryMaterialOptions materialOptions)
|
||||
{
|
||||
_materialOptions = materialOptions;
|
||||
}
|
||||
|
||||
public Color FeatureColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return _materialOptions.colorStyleColor;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_materialOptions.colorStyleColor != value)
|
||||
{
|
||||
_materialOptions.colorStyleColor = value;
|
||||
_materialOptions.HasChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetAsStyle()
|
||||
{
|
||||
SetAsStyle(Color.white);
|
||||
}
|
||||
|
||||
public void SetAsStyle(Color featureColor)
|
||||
{
|
||||
_materialOptions.style = StyleTypes.Color;
|
||||
_materialOptions.colorStyleColor = featureColor;
|
||||
_materialOptions.HasChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a01ce7b00f9c041ad85644335a300fa9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,69 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
public class SubLayerCustomStyle : ISubLayerCustomStyle
|
||||
{
|
||||
private GeometryMaterialOptions _materialOptions;
|
||||
public SubLayerCustomStyle(GeometryMaterialOptions materialOptions)
|
||||
{
|
||||
_materialOptions = materialOptions;
|
||||
}
|
||||
|
||||
public UvMapType TexturingType
|
||||
{
|
||||
get
|
||||
{
|
||||
return _materialOptions.texturingType;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_materialOptions.texturingType != value)
|
||||
{
|
||||
_materialOptions.texturingType = value;
|
||||
_materialOptions.HasChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
private SubLayerCustomStyleTiled _tiled;
|
||||
public ISubLayerCustomStyleTiled Tiled
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_tiled == null)
|
||||
{
|
||||
_tiled = new SubLayerCustomStyleTiled(_materialOptions);
|
||||
}
|
||||
return _tiled;
|
||||
}
|
||||
}
|
||||
|
||||
private SubLayerCustomStyleAtlas _textureAtlas;
|
||||
public ISubLayerCustomStyleAtlas TextureAtlas
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_textureAtlas == null)
|
||||
{
|
||||
_textureAtlas = new SubLayerCustomStyleAtlas(_materialOptions);
|
||||
}
|
||||
return _textureAtlas;
|
||||
}
|
||||
}
|
||||
|
||||
private SubLayerCustomStyleAtlasWithColorPallete _textureAtlasPallete;
|
||||
public ISubLayerCustomStyleAtlasWithColorPallete TextureAtlasWithColorPallete
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_textureAtlasPallete == null)
|
||||
{
|
||||
_textureAtlasPallete = new SubLayerCustomStyleAtlasWithColorPallete(_materialOptions);
|
||||
}
|
||||
return _textureAtlasPallete;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 266c669d1b70b40a88bec6b9193722ac
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,78 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using UnityEngine;
|
||||
using Mapbox.Unity.MeshGeneration.Data;
|
||||
|
||||
public class SubLayerCustomStyleAtlas : ISubLayerCustomStyleAtlas
|
||||
{
|
||||
private GeometryMaterialOptions _materialOptions;
|
||||
public SubLayerCustomStyleAtlas(GeometryMaterialOptions materialOptions)
|
||||
{
|
||||
_materialOptions = materialOptions;
|
||||
}
|
||||
public Material TopMaterial
|
||||
{
|
||||
get
|
||||
{
|
||||
return _materialOptions.customStyleOptions.materials[0].Materials[0];
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_materialOptions.customStyleOptions.materials[0].Materials[0] != value)
|
||||
{
|
||||
_materialOptions.customStyleOptions.materials[0].Materials[0] = value;
|
||||
_materialOptions.HasChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
public Material SideMaterial
|
||||
{
|
||||
get
|
||||
{
|
||||
return _materialOptions.customStyleOptions.materials[1].Materials[0];
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_materialOptions.customStyleOptions.materials[1].Materials[0] != value)
|
||||
{
|
||||
_materialOptions.customStyleOptions.materials[1].Materials[0] = value;
|
||||
_materialOptions.HasChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public AtlasInfo UvAtlas
|
||||
{
|
||||
get
|
||||
{
|
||||
return _materialOptions.customStyleOptions.atlasInfo;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_materialOptions.customStyleOptions.atlasInfo != value)
|
||||
{
|
||||
_materialOptions.customStyleOptions.atlasInfo = value;
|
||||
_materialOptions.HasChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void SetAsStyle(Material topMaterial, Material sideMaterial, AtlasInfo uvAtlas)
|
||||
{
|
||||
_materialOptions.customStyleOptions.texturingType = UvMapType.Atlas;
|
||||
_materialOptions.customStyleOptions.materials[0].Materials[0] = topMaterial;
|
||||
_materialOptions.customStyleOptions.materials[1].Materials[0] = sideMaterial;
|
||||
_materialOptions.customStyleOptions.atlasInfo = uvAtlas;
|
||||
_materialOptions.HasChanged = true;
|
||||
}
|
||||
|
||||
public void SetAsStyle()
|
||||
{
|
||||
_materialOptions.customStyleOptions.SetDefaultAssets();
|
||||
_materialOptions.HasChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0091ed13b56ab49afa140339b816b763
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,98 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using UnityEngine;
|
||||
using Mapbox.Unity.MeshGeneration.Data;
|
||||
|
||||
public class SubLayerCustomStyleAtlasWithColorPallete : ISubLayerCustomStyleAtlasWithColorPallete
|
||||
{
|
||||
private GeometryMaterialOptions _materialOptions;
|
||||
public SubLayerCustomStyleAtlasWithColorPallete(GeometryMaterialOptions materialOptions)
|
||||
{
|
||||
_materialOptions = materialOptions;
|
||||
}
|
||||
|
||||
public Material TopMaterial
|
||||
{
|
||||
get
|
||||
{
|
||||
return _materialOptions.materials[0].Materials[0];
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_materialOptions.materials[0].Materials[0] != value)
|
||||
{
|
||||
_materialOptions.materials[0].Materials[0] = value;
|
||||
_materialOptions.HasChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
public Material SideMaterial
|
||||
{
|
||||
get
|
||||
{
|
||||
return _materialOptions.materials[1].Materials[0];
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_materialOptions.materials[1].Materials[0] != value)
|
||||
{
|
||||
_materialOptions.materials[1].Materials[0] = value;
|
||||
_materialOptions.HasChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public AtlasInfo UvAtlas
|
||||
{
|
||||
get
|
||||
{
|
||||
return _materialOptions.atlasInfo;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_materialOptions.atlasInfo != value)
|
||||
{
|
||||
_materialOptions.atlasInfo = value;
|
||||
_materialOptions.HasChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ScriptablePalette ColorPalette
|
||||
{
|
||||
get
|
||||
{
|
||||
return _materialOptions.colorPalette;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_materialOptions.colorPalette != value)
|
||||
{
|
||||
_materialOptions.colorPalette = value;
|
||||
_materialOptions.HasChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetAsStyle(Material topMaterial, Material sideMaterial, AtlasInfo uvAtlas, ScriptablePalette palette)
|
||||
{
|
||||
_materialOptions.texturingType = UvMapType.Atlas;
|
||||
_materialOptions.materials[0].Materials[0] = topMaterial;
|
||||
_materialOptions.materials[1].Materials[0] = sideMaterial;
|
||||
_materialOptions.atlasInfo = uvAtlas;
|
||||
_materialOptions.colorPalette = palette;
|
||||
_materialOptions.HasChanged = true;
|
||||
}
|
||||
|
||||
public void SetAsStyle()
|
||||
{
|
||||
_materialOptions.SetDefaultAssets(UvMapType.AtlasWithColorPalette);
|
||||
_materialOptions.HasChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a3d712d45039847a99a4c4a1df68827c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,64 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using UnityEngine;
|
||||
|
||||
public class SubLayerCustomStyleTiled : ISubLayerCustomStyleTiled
|
||||
{
|
||||
private GeometryMaterialOptions _materialOptions;
|
||||
public SubLayerCustomStyleTiled(GeometryMaterialOptions materialOptions)
|
||||
{
|
||||
_materialOptions = materialOptions;
|
||||
}
|
||||
public Material TopMaterial
|
||||
{
|
||||
get
|
||||
{
|
||||
return _materialOptions.materials[0].Materials[0];
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_materialOptions.materials[0].Materials[0] != value)
|
||||
{
|
||||
_materialOptions.materials[0].Materials[0] = value;
|
||||
_materialOptions.HasChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
public Material SideMaterial
|
||||
{
|
||||
get
|
||||
{
|
||||
return _materialOptions.materials[1].Materials[0];
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_materialOptions.materials[1].Materials[0] != value)
|
||||
{
|
||||
_materialOptions.materials[1].Materials[0] = value;
|
||||
_materialOptions.HasChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetAsStyle(Material topMaterial, Material sideMaterial = null)
|
||||
{
|
||||
_materialOptions.texturingType = UvMapType.Tiled;
|
||||
_materialOptions.materials[0].Materials[0] = topMaterial;
|
||||
_materialOptions.materials[1].Materials[0] = sideMaterial;
|
||||
_materialOptions.HasChanged = true;
|
||||
}
|
||||
|
||||
public void SetAsStyle()
|
||||
{
|
||||
SetAsStyle(null, null);
|
||||
}
|
||||
|
||||
public void SetMaterials(Material topMaterial, Material sideMaterial)
|
||||
{
|
||||
SetAsStyle(topMaterial, sideMaterial);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c39cffb4b1ef047e2be2134a6183444f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,40 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
public class SubLayerDarkStyle : ISubLayerDarkStyle
|
||||
{
|
||||
private GeometryMaterialOptions _materialOptions;
|
||||
public SubLayerDarkStyle(GeometryMaterialOptions materialOptions)
|
||||
{
|
||||
_materialOptions = materialOptions;
|
||||
}
|
||||
|
||||
public float Opacity
|
||||
{
|
||||
get
|
||||
{
|
||||
return _materialOptions.darkStyleOpacity;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
_materialOptions.darkStyleOpacity = value;
|
||||
_materialOptions.HasChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetAsStyle()
|
||||
{
|
||||
SetAsStyle(1.0f);
|
||||
}
|
||||
|
||||
public void SetAsStyle(float opacity)
|
||||
{
|
||||
_materialOptions.style = StyleTypes.Light;
|
||||
_materialOptions.darkStyleOpacity = opacity;
|
||||
_materialOptions.HasChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7d55a2e41465546e99410e822cbb622e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,19 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
public class SubLayerFantasyStyle : ISubLayerFantasyStyle
|
||||
{
|
||||
private GeometryMaterialOptions _materialOptions;
|
||||
public SubLayerFantasyStyle(GeometryMaterialOptions materialOptions)
|
||||
{
|
||||
_materialOptions = materialOptions;
|
||||
}
|
||||
public void SetAsStyle()
|
||||
{
|
||||
_materialOptions.style = StyleTypes.Fantasy;
|
||||
_materialOptions.HasChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2799484baa53f492bbba93c9731b9e52
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,40 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
public class SubLayerLightStyle : ISubLayerLightStyle
|
||||
{
|
||||
private GeometryMaterialOptions _materialOptions;
|
||||
public SubLayerLightStyle(GeometryMaterialOptions materialOptions)
|
||||
{
|
||||
_materialOptions = materialOptions;
|
||||
}
|
||||
|
||||
public float Opacity
|
||||
{
|
||||
get
|
||||
{
|
||||
return _materialOptions.lightStyleOpacity;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
_materialOptions.lightStyleOpacity = value;
|
||||
_materialOptions.HasChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetAsStyle()
|
||||
{
|
||||
SetAsStyle(1.0f);
|
||||
}
|
||||
|
||||
public void SetAsStyle(float opacity)
|
||||
{
|
||||
_materialOptions.style = StyleTypes.Light;
|
||||
_materialOptions.lightStyleOpacity = opacity;
|
||||
_materialOptions.HasChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8ede91ec4657e404a87fa5bbe582cdb6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,64 @@
|
||||
using Mapbox.Unity.Map;
|
||||
|
||||
namespace Mapbox.Unity.SourceLayers
|
||||
{
|
||||
public class SubLayerModeling : ISubLayerModeling
|
||||
{
|
||||
VectorSubLayerProperties _subLayerProperties;
|
||||
|
||||
public SubLayerModeling(VectorSubLayerProperties subLayerProperties)
|
||||
{
|
||||
_subLayerProperties = subLayerProperties;
|
||||
}
|
||||
|
||||
public ISubLayerCoreOptions CoreOptions
|
||||
{
|
||||
get { return _subLayerProperties.coreOptions; }
|
||||
}
|
||||
|
||||
public ISubLayerExtrusionOptions ExtrusionOptions
|
||||
{
|
||||
get { return _subLayerProperties.extrusionOptions; }
|
||||
}
|
||||
|
||||
public ISubLayerColliderOptions ColliderOptions
|
||||
{
|
||||
get { return _subLayerProperties.colliderOptions; }
|
||||
}
|
||||
|
||||
public ISubLayerLineGeometryOptions LineOptions
|
||||
{
|
||||
get { return _subLayerProperties.lineGeometryOptions; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enable terrain snapping for features which sets vertices to terrain
|
||||
/// elevation before extrusion.
|
||||
/// </summary>
|
||||
/// <param name="isEnabled">Enabled terrain snapping</param>
|
||||
public virtual void EnableSnapingTerrain(bool isEnabled)
|
||||
{
|
||||
if (_subLayerProperties.coreOptions.snapToTerrain != isEnabled)
|
||||
{
|
||||
_subLayerProperties.coreOptions.snapToTerrain = isEnabled;
|
||||
_subLayerProperties.coreOptions.HasChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enable combining individual features meshes into one to minimize gameobject
|
||||
/// count and draw calls.
|
||||
/// </summary>
|
||||
/// <param name="isEnabled"></param>
|
||||
public virtual void EnableCombiningMeshes(bool isEnabled)
|
||||
{
|
||||
if (_subLayerProperties.coreOptions.combineMeshes != isEnabled)
|
||||
{
|
||||
_subLayerProperties.coreOptions.combineMeshes = isEnabled;
|
||||
_subLayerProperties.coreOptions.HasChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ed8cfcdd6f584912ba4f749445adc3b4
|
||||
timeCreated: 1538171546
|
||||
@@ -0,0 +1,19 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
public class SubLayerRealisticStyle : ISubLayerRealisticStyle
|
||||
{
|
||||
private GeometryMaterialOptions _materialOptions;
|
||||
public SubLayerRealisticStyle(GeometryMaterialOptions materialOptions)
|
||||
{
|
||||
_materialOptions = materialOptions;
|
||||
}
|
||||
public void SetAsStyle()
|
||||
{
|
||||
_materialOptions.style = StyleTypes.Realistic;
|
||||
_materialOptions.HasChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aae18f819ca0c4f37a4882c43ffe04f1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,43 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
public class SubLayerSimpleStyle : ISubLayerSimpleStyle
|
||||
{
|
||||
private GeometryMaterialOptions _materialOptions;
|
||||
public SubLayerSimpleStyle(GeometryMaterialOptions materialOptions)
|
||||
{
|
||||
_materialOptions = materialOptions;
|
||||
}
|
||||
|
||||
public SamplePalettes PaletteType
|
||||
{
|
||||
get
|
||||
{
|
||||
return _materialOptions.samplePalettes;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_materialOptions.samplePalettes != value)
|
||||
{
|
||||
_materialOptions.samplePalettes = value;
|
||||
_materialOptions.HasChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetAsStyle()
|
||||
{
|
||||
SetAsStyle(SamplePalettes.City);
|
||||
}
|
||||
|
||||
public void SetAsStyle(SamplePalettes palette)
|
||||
{
|
||||
_materialOptions.style = StyleTypes.Fantasy;
|
||||
_materialOptions.samplePalettes = palette;
|
||||
_materialOptions.HasChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: de75de3987dab4beaa381b91d5946df1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
374
Assets/Mapbox SDK/Mapbox/Unity/SourceLayers/TerrainLayer.cs
Normal file
374
Assets/Mapbox SDK/Mapbox/Unity/SourceLayers/TerrainLayer.cs
Normal file
@@ -0,0 +1,374 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using Mapbox.Unity.MeshGeneration.Factories;
|
||||
using Mapbox.Unity.Utilities;
|
||||
using Mapbox.Unity.MeshGeneration.Factories.TerrainStrategies;
|
||||
|
||||
// Layer Concrete Implementation.
|
||||
[Serializable]
|
||||
public class TerrainLayer : AbstractLayer, ITerrainLayer, IGlobeTerrainLayer
|
||||
{
|
||||
[SerializeField]
|
||||
[NodeEditorElement("Terrain Layer")]
|
||||
ElevationLayerProperties _layerProperty = new ElevationLayerProperties();
|
||||
[NodeEditorElement("Terrain Layer")]
|
||||
public ElevationLayerProperties LayerProperty
|
||||
{
|
||||
get
|
||||
{
|
||||
return _layerProperty;
|
||||
}
|
||||
}
|
||||
|
||||
public MapLayerType LayerType
|
||||
{
|
||||
get
|
||||
{
|
||||
return MapLayerType.Elevation;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsLayerActive
|
||||
{
|
||||
get
|
||||
{
|
||||
return (_layerProperty.sourceType != ElevationSourceType.None);
|
||||
}
|
||||
}
|
||||
|
||||
public string LayerSourceId
|
||||
{
|
||||
get
|
||||
{
|
||||
return _layerProperty.sourceOptions.Id;
|
||||
}
|
||||
}
|
||||
|
||||
public ElevationSourceType LayerSource
|
||||
{
|
||||
get
|
||||
{
|
||||
return _layerProperty.sourceType;
|
||||
}
|
||||
}
|
||||
|
||||
public ElevationLayerType ElevationType
|
||||
{
|
||||
get
|
||||
{
|
||||
return _layerProperty.elevationLayerType;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_layerProperty.elevationLayerType != value)
|
||||
{
|
||||
_layerProperty.elevationLayerType = value;
|
||||
_layerProperty.HasChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
public float ExaggerationFactor
|
||||
{
|
||||
get
|
||||
{
|
||||
return _layerProperty.requiredOptions.exaggerationFactor;
|
||||
}
|
||||
set
|
||||
{
|
||||
_layerProperty.requiredOptions.exaggerationFactor = value;
|
||||
_layerProperty.requiredOptions.HasChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
public float EarthRadius
|
||||
{
|
||||
get
|
||||
{
|
||||
return _layerProperty.modificationOptions.earthRadius;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
_layerProperty.modificationOptions.earthRadius = value;
|
||||
}
|
||||
}
|
||||
private TerrainFactoryBase _elevationFactory;
|
||||
public AbstractTileFactory Factory
|
||||
{
|
||||
get
|
||||
{
|
||||
return _elevationFactory;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public TerrainLayer()
|
||||
{
|
||||
}
|
||||
|
||||
public TerrainLayer(ElevationLayerProperties properties)
|
||||
{
|
||||
_layerProperty = properties;
|
||||
}
|
||||
|
||||
public void Initialize(LayerProperties properties)
|
||||
{
|
||||
_layerProperty = (ElevationLayerProperties)properties;
|
||||
|
||||
Initialize();
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
_elevationFactory = ScriptableObject.CreateInstance<TerrainFactoryBase>();
|
||||
SetFactoryOptions();
|
||||
|
||||
_layerProperty.colliderOptions.PropertyHasChanged += (property, e) =>
|
||||
{
|
||||
NotifyUpdateLayer(_elevationFactory, property as MapboxDataProperty, true);
|
||||
};
|
||||
_layerProperty.requiredOptions.PropertyHasChanged += (property, e) =>
|
||||
{
|
||||
NotifyUpdateLayer(_elevationFactory, property as MapboxDataProperty, true);
|
||||
};
|
||||
_layerProperty.unityLayerOptions.PropertyHasChanged += (property, e) =>
|
||||
{
|
||||
NotifyUpdateLayer(_elevationFactory, property as MapboxDataProperty, true);
|
||||
};
|
||||
_layerProperty.PropertyHasChanged += (property, e) =>
|
||||
{
|
||||
//terrain factory uses strategy objects and they are controlled by layer
|
||||
//so we have to refresh that first
|
||||
//pushing new settings to factory directly
|
||||
SetFactoryOptions();
|
||||
//notifying map to reload existing tiles
|
||||
NotifyUpdateLayer(_elevationFactory, property as MapboxDataProperty, true);
|
||||
};
|
||||
}
|
||||
// public void RedrawLayer(object sender, System.EventArgs e)
|
||||
// {
|
||||
// SetFactoryOptions();
|
||||
// //notifying map to reload existing tiles
|
||||
// NotifyUpdateLayer(_elevationFactory, property as MapboxDataProperty, false);
|
||||
// }
|
||||
|
||||
private void SetFactoryOptions()
|
||||
{
|
||||
//terrain factory uses strategy objects and they are controlled by layer
|
||||
//so we have to refresh that first
|
||||
SetStrategy();
|
||||
//pushing new settings to factory directly
|
||||
Factory.SetOptions(_layerProperty);
|
||||
}
|
||||
|
||||
private void SetStrategy()
|
||||
{
|
||||
switch (_layerProperty.elevationLayerType)
|
||||
{
|
||||
case ElevationLayerType.FlatTerrain:
|
||||
_elevationFactory.Strategy = new FlatTerrainStrategy();
|
||||
break;
|
||||
case ElevationLayerType.LowPolygonTerrain:
|
||||
_elevationFactory.Strategy = new LowPolyTerrainStrategy();
|
||||
break;
|
||||
case ElevationLayerType.TerrainWithElevation:
|
||||
if (_layerProperty.sideWallOptions.isActive)
|
||||
{
|
||||
_elevationFactory.Strategy = new ElevatedTerrainWithSidesStrategy();
|
||||
}
|
||||
else
|
||||
{
|
||||
_elevationFactory.Strategy = new ElevatedTerrainStrategy();
|
||||
}
|
||||
break;
|
||||
case ElevationLayerType.GlobeTerrain:
|
||||
_elevationFactory.Strategy = new FlatSphereTerrainStrategy();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void Remove()
|
||||
{
|
||||
_layerProperty = new ElevationLayerProperties
|
||||
{
|
||||
sourceType = ElevationSourceType.None
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(LayerProperties properties)
|
||||
{
|
||||
Initialize(properties);
|
||||
}
|
||||
|
||||
#region API Methods
|
||||
|
||||
/// <summary>
|
||||
/// Sets the data source for Terrain Layer.
|
||||
/// Defaults to MapboxTerrain.
|
||||
/// Use <paramref name="terrainSource"/> = None, to disable the Terrain Layer.
|
||||
/// </summary>
|
||||
/// <param name="terrainSource">Terrain source.</param>
|
||||
public virtual void SetLayerSource(ElevationSourceType terrainSource = ElevationSourceType.MapboxTerrain)
|
||||
{
|
||||
if (terrainSource != ElevationSourceType.Custom && terrainSource != ElevationSourceType.None)
|
||||
{
|
||||
_layerProperty.sourceType = terrainSource;
|
||||
_layerProperty.sourceOptions.layerSource = MapboxDefaultElevation.GetParameters(terrainSource);
|
||||
_layerProperty.HasChanged = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("Invalid style - trying to set " + terrainSource.ToString() + " as default style!");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the data source to a custom source for Terrain Layer.
|
||||
/// </summary>
|
||||
/// <param name="terrainSource">Terrain source.</param>
|
||||
public virtual void SetLayerSource(string terrainSource)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(terrainSource))
|
||||
{
|
||||
_layerProperty.sourceType = ElevationSourceType.Custom;
|
||||
_layerProperty.sourceOptions.Id = terrainSource;
|
||||
}
|
||||
else
|
||||
{
|
||||
_layerProperty.sourceType = ElevationSourceType.None;
|
||||
_layerProperty.elevationLayerType = ElevationLayerType.FlatTerrain;
|
||||
Debug.LogWarning("Empty source - turning off terrain. ");
|
||||
}
|
||||
_layerProperty.HasChanged = true;
|
||||
}
|
||||
/// <summary>
|
||||
/// Sets the main strategy for terrain mesh generation.
|
||||
/// Flat terrain doesn't pull data from servers and just uses a quad as terrain.
|
||||
/// </summary>
|
||||
/// <param name="elevationType">Type of the elevation strategy</param>
|
||||
public virtual void SetElevationType(ElevationLayerType elevationType)
|
||||
{
|
||||
if (_layerProperty.elevationLayerType != elevationType)
|
||||
{
|
||||
_layerProperty.elevationLayerType = elevationType;
|
||||
_layerProperty.HasChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add/Remove terrain collider. Terrain uses mesh collider.
|
||||
/// </summary>
|
||||
/// <param name="enable">Boolean for enabling/disabling mesh collider</param>
|
||||
public virtual void EnableCollider(bool enable)
|
||||
{
|
||||
if (_layerProperty.colliderOptions.addCollider != enable)
|
||||
{
|
||||
_layerProperty.colliderOptions.addCollider = enable;
|
||||
_layerProperty.colliderOptions.HasChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the elevation multiplier for terrain. It'll regenerate terrain mesh, multiplying each point elevation by provided value.
|
||||
/// </summary>
|
||||
/// <param name="factor">Elevation multiplier</param>
|
||||
public virtual void SetExaggerationFactor(float factor)
|
||||
{
|
||||
if (_layerProperty.requiredOptions.exaggerationFactor != factor)
|
||||
{
|
||||
_layerProperty.requiredOptions.exaggerationFactor = factor;
|
||||
_layerProperty.requiredOptions.HasChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Turn on terrain side walls.
|
||||
/// </summary>
|
||||
/// <param name="wallHeight">Wall height.</param>
|
||||
/// <param name="wallMaterial">Wall material.</param>
|
||||
public virtual void EnableSideWalls(float wallHeight, Material wallMaterial)
|
||||
{
|
||||
_layerProperty.sideWallOptions.isActive = true;
|
||||
_layerProperty.sideWallOptions.wallHeight = wallHeight;
|
||||
_layerProperty.sideWallOptions.wallMaterial = wallMaterial;
|
||||
_layerProperty.HasChanged = true;
|
||||
}
|
||||
public void DisableSideWalls()
|
||||
{
|
||||
_layerProperty.sideWallOptions.isActive = false;
|
||||
_layerProperty.HasChanged = true;
|
||||
}
|
||||
|
||||
public void RemoveFromUnityLayer(int layerId)
|
||||
{
|
||||
if (_layerProperty.unityLayerOptions.layerId == layerId)
|
||||
{
|
||||
_layerProperty.unityLayerOptions.addToLayer = false;
|
||||
_layerProperty.HasChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds Terrain GameObject to Unity layer.
|
||||
/// </summary>
|
||||
/// <param name="layerId">Layer identifier.</param>
|
||||
public virtual void AddToUnityLayer(int layerId)
|
||||
{
|
||||
if (_layerProperty.unityLayerOptions.layerId != layerId)
|
||||
{
|
||||
_layerProperty.unityLayerOptions.addToLayer = true;
|
||||
_layerProperty.unityLayerOptions.layerId = layerId;
|
||||
_layerProperty.HasChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Change terrain layer settings.
|
||||
/// </summary>
|
||||
/// <param name="dataSource">The data source for the terrain height map.</param>
|
||||
/// <param name="elevationType">Mesh generation strategy for the tile/height.</param>
|
||||
/// <param name="enableCollider">Enable/Disable collider component for the tile game object.</param>
|
||||
/// <param name="factor">Multiplier for the height data.</param>
|
||||
/// <param name="layerId">Unity Layer for the tile game object.</param>
|
||||
public virtual void SetProperties(ElevationSourceType dataSource = ElevationSourceType.MapboxTerrain,
|
||||
ElevationLayerType elevationType = ElevationLayerType.TerrainWithElevation,
|
||||
bool enableCollider = false,
|
||||
float factor = 1,
|
||||
int layerId = 0)
|
||||
{
|
||||
if (_layerProperty.sourceType != dataSource ||
|
||||
_layerProperty.elevationLayerType != elevationType)
|
||||
{
|
||||
_layerProperty.sourceType = dataSource;
|
||||
_layerProperty.elevationLayerType = elevationType;
|
||||
_layerProperty.HasChanged = true;
|
||||
}
|
||||
|
||||
if (_layerProperty.colliderOptions.addCollider != enableCollider)
|
||||
{
|
||||
_layerProperty.colliderOptions.addCollider = enableCollider;
|
||||
_layerProperty.colliderOptions.HasChanged = true;
|
||||
}
|
||||
|
||||
if (_layerProperty.requiredOptions.exaggerationFactor != factor)
|
||||
{
|
||||
_layerProperty.requiredOptions.exaggerationFactor = factor;
|
||||
_layerProperty.requiredOptions.HasChanged = true;
|
||||
}
|
||||
|
||||
if (_layerProperty.unityLayerOptions.layerId != layerId)
|
||||
{
|
||||
_layerProperty.unityLayerOptions.layerId = layerId;
|
||||
_layerProperty.unityLayerOptions.HasChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e443cd3cf7e5244aeb3ef573767b000b
|
||||
timeCreated: 1519860268
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
650
Assets/Mapbox SDK/Mapbox/Unity/SourceLayers/VectorLayer.cs
Normal file
650
Assets/Mapbox SDK/Mapbox/Unity/SourceLayers/VectorLayer.cs
Normal file
@@ -0,0 +1,650 @@
|
||||
using System.Linq;
|
||||
using Mapbox.Utils;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using Mapbox.Unity.MeshGeneration.Factories;
|
||||
using Mapbox.Unity.Utilities;
|
||||
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
[Serializable]
|
||||
public class VectorLayer : AbstractLayer, IVectorDataLayer
|
||||
{
|
||||
//Private Fields
|
||||
[SerializeField]
|
||||
private VectorLayerProperties _layerProperty = new VectorLayerProperties();
|
||||
private VectorTileFactory _vectorTileFactory;
|
||||
|
||||
//Events
|
||||
public EventHandler SubLayerAdded;
|
||||
public EventHandler SubLayerRemoved;
|
||||
|
||||
//Properties
|
||||
[NodeEditorElement(" Vector Layer ")]
|
||||
public VectorLayerProperties LayerProperty
|
||||
{
|
||||
get
|
||||
{
|
||||
return _layerProperty;
|
||||
}
|
||||
}
|
||||
public MapLayerType LayerType
|
||||
{
|
||||
get
|
||||
{
|
||||
return MapLayerType.Vector;
|
||||
}
|
||||
}
|
||||
public bool IsLayerActive
|
||||
{
|
||||
get
|
||||
{
|
||||
return (_layerProperty.sourceType != VectorSourceType.None);
|
||||
}
|
||||
}
|
||||
public string LayerSourceId
|
||||
{
|
||||
get
|
||||
{
|
||||
return _layerProperty.sourceOptions.Id;
|
||||
}
|
||||
}
|
||||
public VectorTileFactory Factory
|
||||
{
|
||||
get
|
||||
{
|
||||
return _vectorTileFactory;
|
||||
}
|
||||
}
|
||||
|
||||
//Public Methods
|
||||
public void Initialize(LayerProperties properties)
|
||||
{
|
||||
_layerProperty = (VectorLayerProperties)properties;
|
||||
Initialize();
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
_vectorTileFactory = ScriptableObject.CreateInstance<VectorTileFactory>();
|
||||
UpdateFactorySettings();
|
||||
|
||||
_layerProperty.PropertyHasChanged += RedrawVectorLayer;
|
||||
_layerProperty.SubLayerPropertyAdded += AddVectorLayer;
|
||||
_layerProperty.SubLayerPropertyRemoved += RemoveVectorLayer;
|
||||
_vectorTileFactory.TileFactoryHasChanged += (sender, args) =>
|
||||
{
|
||||
NotifyUpdateLayer(args as LayerUpdateArgs);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
public void Update(LayerProperties properties)
|
||||
{
|
||||
Initialize(properties);
|
||||
}
|
||||
|
||||
public void UnbindAllEvents()
|
||||
{
|
||||
_vectorTileFactory.UnbindEvents();
|
||||
}
|
||||
|
||||
public void UpdateFactorySettings()
|
||||
{
|
||||
_vectorTileFactory.SetOptions(_layerProperty);
|
||||
}
|
||||
|
||||
public void Remove()
|
||||
{
|
||||
_layerProperty = new VectorLayerProperties
|
||||
{
|
||||
sourceType = VectorSourceType.None
|
||||
};
|
||||
}
|
||||
|
||||
//Private Methods
|
||||
private void AddVectorLayer(object sender, EventArgs args)
|
||||
{
|
||||
VectorLayerUpdateArgs layerUpdateArgs = args as VectorLayerUpdateArgs;
|
||||
if (layerUpdateArgs.property is PrefabItemOptions)
|
||||
{
|
||||
layerUpdateArgs.visualizer =
|
||||
_vectorTileFactory.AddPOIVectorLayerVisualizer((PrefabItemOptions)layerUpdateArgs.property);
|
||||
}
|
||||
else if (layerUpdateArgs.property is VectorSubLayerProperties)
|
||||
{
|
||||
layerUpdateArgs.visualizer =
|
||||
_vectorTileFactory.AddVectorLayerVisualizer((VectorSubLayerProperties)layerUpdateArgs.property);
|
||||
}
|
||||
|
||||
layerUpdateArgs.factory = _vectorTileFactory;
|
||||
|
||||
SubLayerAdded(this, layerUpdateArgs);
|
||||
}
|
||||
|
||||
private void RemoveVectorLayer(object sender, EventArgs args)
|
||||
{
|
||||
VectorLayerUpdateArgs layerUpdateArgs = args as VectorLayerUpdateArgs;
|
||||
|
||||
layerUpdateArgs.visualizer = _vectorTileFactory.FindVectorLayerVisualizer((VectorSubLayerProperties)layerUpdateArgs.property);
|
||||
layerUpdateArgs.factory = _vectorTileFactory;
|
||||
|
||||
SubLayerRemoved(this, layerUpdateArgs);
|
||||
}
|
||||
|
||||
private void RedrawVectorLayer(object sender, System.EventArgs e)
|
||||
{
|
||||
NotifyUpdateLayer(_vectorTileFactory, sender as MapboxDataProperty, true);
|
||||
}
|
||||
|
||||
#region Api Methods
|
||||
|
||||
public virtual TileJsonData GetTileJsonData()
|
||||
{
|
||||
return _layerProperty.tileJsonData;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add provided data source (mapid) to existing ones.
|
||||
/// Mapbox vector api supports comma separated mapids and this method
|
||||
/// adds the provided mapid at the end of the existing source.
|
||||
/// </summary>
|
||||
/// <param name="vectorSource">Data source (Mapid) to add to existing sources.</param>
|
||||
public virtual void AddLayerSource(string vectorSource)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(vectorSource))
|
||||
{
|
||||
if (!_layerProperty.sourceOptions.Id.Contains(vectorSource))
|
||||
{
|
||||
if (string.IsNullOrEmpty(_layerProperty.sourceOptions.Id))
|
||||
{
|
||||
SetLayerSource(vectorSource);
|
||||
return;
|
||||
}
|
||||
var newLayerSource = _layerProperty.sourceOptions.Id + "," + vectorSource;
|
||||
SetLayerSource(newLayerSource);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("Empty source. Nothing was added to the list of data sources");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Change existing data source (mapid) with provided source.
|
||||
/// </summary>
|
||||
/// <param name="vectorSource">Data source (Mapid) to use.</param>
|
||||
public virtual void SetLayerSource(string vectorSource)
|
||||
{
|
||||
SetLayerSourceInternal(vectorSource);
|
||||
_layerProperty.HasChanged = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Change existing data source (mapid) with provided source.
|
||||
/// </summary>
|
||||
/// <param name="vectorSource">Data source (Mapid) to use.</param>
|
||||
public virtual void SetLayerSource(VectorSourceType vectorSource)
|
||||
{
|
||||
SetLayerSourceInternal(vectorSource);
|
||||
_layerProperty.HasChanged = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the layer source as Style-optimized vector tiles
|
||||
/// </summary>
|
||||
/// <param name="vectorSource">Vector source.</param>
|
||||
/// <param name="styleId">Style-Optimized style id.</param>
|
||||
/// <param name="modifiedDate">Modified date.</param>
|
||||
/// <param name="styleName">Style name.</param>
|
||||
public virtual void SetLayerSourceWithOptimizedStyle(string vectorSource, string styleId, string modifiedDate, string styleName = null)
|
||||
{
|
||||
SetLayerSourceInternal(vectorSource);
|
||||
SetOptimizedStyleInternal(styleId, modifiedDate, styleName);
|
||||
_layerProperty.HasChanged = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the layer source as Style-optimized vector tiles
|
||||
/// </summary>
|
||||
/// <param name="vectorSource">Vector source.</param>
|
||||
/// <param name="styleId">Style-Optimized style id.</param>
|
||||
/// <param name="modifiedDate">Modified date.</param>
|
||||
/// <param name="styleName">Style name.</param>
|
||||
public virtual void SetLayerSourceWithOptimizedStyle(VectorSourceType vectorSource, string styleId, string modifiedDate, string styleName = null)
|
||||
{
|
||||
SetLayerSourceInternal(vectorSource);
|
||||
SetOptimizedStyleInternal(styleId, modifiedDate, styleName);
|
||||
_layerProperty.HasChanged = true;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Enable coroutines for vector features, processing choosen amount
|
||||
/// of them each frame.
|
||||
/// </summary>
|
||||
/// <param name="entityPerCoroutine">Numbers of features to process each frame.</param>
|
||||
///
|
||||
public virtual void EnableVectorFeatureProcessingWithCoroutines(int entityPerCoroutine = 20)
|
||||
{
|
||||
if (_layerProperty.performanceOptions.isEnabled != true ||
|
||||
_layerProperty.performanceOptions.entityPerCoroutine != entityPerCoroutine)
|
||||
{
|
||||
_layerProperty.performanceOptions.isEnabled = true;
|
||||
_layerProperty.performanceOptions.entityPerCoroutine = entityPerCoroutine;
|
||||
_layerProperty.performanceOptions.HasChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void DisableVectorFeatureProcessingWithCoroutines()
|
||||
{
|
||||
_layerProperty.performanceOptions.isEnabled = false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Poi Api Methods
|
||||
|
||||
/// <summary>
|
||||
/// Creates the prefab layer.
|
||||
/// </summary>
|
||||
/// <param name="item"> the options of the prefab layer.</param>
|
||||
private void CreatePrefabLayer(PrefabItemOptions item)
|
||||
{
|
||||
if (LayerProperty.sourceType == VectorSourceType.None
|
||||
|| !LayerProperty.sourceOptions.Id.Contains(MapboxDefaultVector.GetParameters(VectorSourceType.MapboxStreets).Id))
|
||||
{
|
||||
Debug.LogError("In order to place location prefabs please add \"mapbox.mapbox-streets-v7\" to the list of vector data sources");
|
||||
return;
|
||||
}
|
||||
|
||||
AddPointsOfInterestSubLayer(item);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Places a prefab at the specified LatLon on the Map.
|
||||
/// </summary>
|
||||
/// <param name="prefab"> A Game Object Prefab.</param>
|
||||
/// <param name="LatLon">A Vector2d(Latitude Longitude) object</param>
|
||||
public virtual void SpawnPrefabAtGeoLocation(GameObject prefab,
|
||||
Vector2d LatLon,
|
||||
Action<List<GameObject>> callback = null,
|
||||
bool scaleDownWithWorld = true,
|
||||
string locationItemName = "New Location")
|
||||
{
|
||||
var latLonArray = new Vector2d[] { LatLon };
|
||||
SpawnPrefabAtGeoLocation(prefab, latLonArray, callback, scaleDownWithWorld, locationItemName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Places a prefab at all locations specified by the LatLon array.
|
||||
/// </summary>
|
||||
/// <param name="prefab"> A Game Object Prefab.</param>
|
||||
/// <param name="LatLon">A Vector2d(Latitude Longitude) object</param>
|
||||
public virtual void SpawnPrefabAtGeoLocation(GameObject prefab,
|
||||
Vector2d[] LatLon,
|
||||
Action<List<GameObject>> callback = null,
|
||||
bool scaleDownWithWorld = true,
|
||||
string locationItemName = "New Location")
|
||||
{
|
||||
var coordinateArray = new string[LatLon.Length];
|
||||
for (int i = 0; i < LatLon.Length; i++)
|
||||
{
|
||||
coordinateArray[i] = LatLon[i].x + ", " + LatLon[i].y;
|
||||
}
|
||||
|
||||
PrefabItemOptions item = new PrefabItemOptions()
|
||||
{
|
||||
findByType = LocationPrefabFindBy.AddressOrLatLon,
|
||||
prefabItemName = locationItemName,
|
||||
spawnPrefabOptions = new SpawnPrefabOptions()
|
||||
{
|
||||
prefab = prefab,
|
||||
scaleDownWithWorld = scaleDownWithWorld
|
||||
},
|
||||
|
||||
coordinates = coordinateArray
|
||||
};
|
||||
|
||||
if (callback != null)
|
||||
{
|
||||
item.OnAllPrefabsInstantiated += callback;
|
||||
}
|
||||
|
||||
CreatePrefabLayer(item);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Places the prefab for supplied categories.
|
||||
/// </summary>
|
||||
/// <param name="prefab">GameObject Prefab</param>
|
||||
/// <param name="categories"><see cref="LocationPrefabCategories"/> For more than one category separate them by pipe
|
||||
/// (eg: LocationPrefabCategories.Food | LocationPrefabCategories.Nightlife)</param>
|
||||
/// <param name="density">Density controls the number of POIs on the map.(Integer value between 1 and 30)</param>
|
||||
/// <param name="locationItemName">Name of this location prefab item for future reference</param>
|
||||
/// <param name="scaleDownWithWorld">Should the prefab scale up/down along with the map game object?</param>
|
||||
public virtual void SpawnPrefabByCategory(GameObject prefab,
|
||||
LocationPrefabCategories categories = LocationPrefabCategories.AnyCategory,
|
||||
int density = 30, Action<List<GameObject>> callback = null,
|
||||
bool scaleDownWithWorld = true,
|
||||
string locationItemName = "New Location")
|
||||
{
|
||||
PrefabItemOptions item = new PrefabItemOptions()
|
||||
{
|
||||
findByType = LocationPrefabFindBy.MapboxCategory,
|
||||
categories = categories,
|
||||
density = density,
|
||||
prefabItemName = locationItemName,
|
||||
spawnPrefabOptions = new SpawnPrefabOptions()
|
||||
{
|
||||
prefab = prefab,
|
||||
scaleDownWithWorld = scaleDownWithWorld
|
||||
}
|
||||
};
|
||||
|
||||
if (callback != null)
|
||||
{
|
||||
item.OnAllPrefabsInstantiated += callback;
|
||||
}
|
||||
|
||||
CreatePrefabLayer(item);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Places the prefab at POI locations if its name contains the supplied string
|
||||
/// <param name="prefab">GameObject Prefab</param>
|
||||
/// <param name="nameString">This is the string that will be checked against the POI name to see if is contained in it, and ony those POIs will be spawned</param>
|
||||
/// <param name="density">Density (Integer value between 1 and 30)</param>
|
||||
/// <param name="locationItemName">Name of this location prefab item for future reference</param>
|
||||
/// <param name="scaleDownWithWorld">Should the prefab scale up/down along with the map game object?</param>
|
||||
/// </summary>
|
||||
public virtual void SpawnPrefabByName(GameObject prefab,
|
||||
string nameString,
|
||||
int density = 30,
|
||||
Action<List<GameObject>> callback = null,
|
||||
bool scaleDownWithWorld = true,
|
||||
string locationItemName = "New Location")
|
||||
{
|
||||
PrefabItemOptions item = new PrefabItemOptions()
|
||||
{
|
||||
findByType = LocationPrefabFindBy.POIName,
|
||||
nameString = nameString,
|
||||
density = density,
|
||||
prefabItemName = locationItemName,
|
||||
spawnPrefabOptions = new SpawnPrefabOptions()
|
||||
{
|
||||
prefab = prefab,
|
||||
scaleDownWithWorld = scaleDownWithWorld
|
||||
}
|
||||
};
|
||||
|
||||
CreatePrefabLayer(item);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region LayerOperations
|
||||
|
||||
// FEATURE LAYER OPERATIONS
|
||||
|
||||
public virtual void AddFeatureSubLayer(VectorSubLayerProperties subLayerProperties)
|
||||
{
|
||||
if (_layerProperty.vectorSubLayers == null)
|
||||
{
|
||||
_layerProperty.vectorSubLayers = new List<VectorSubLayerProperties>();
|
||||
}
|
||||
|
||||
_layerProperty.vectorSubLayers.Add(subLayerProperties);
|
||||
_layerProperty.OnSubLayerPropertyAdded(new VectorLayerUpdateArgs { property = _layerProperty.vectorSubLayers.Last() });
|
||||
}
|
||||
|
||||
public virtual void AddPolygonFeatureSubLayer(string assignedSubLayerName, string dataLayerNameInService)
|
||||
{
|
||||
|
||||
VectorSubLayerProperties subLayer = PresetSubLayerPropertiesFetcher.GetSubLayerProperties(PresetFeatureType.Buildings);
|
||||
subLayer.coreOptions.layerName = dataLayerNameInService;
|
||||
subLayer.coreOptions.sublayerName = assignedSubLayerName;
|
||||
|
||||
AddFeatureSubLayer(subLayer);
|
||||
}
|
||||
public virtual void AddLineFeatureSubLayer(string assignedSubLayerName, string dataLayerNameInService, float lineWidth = 1)
|
||||
{
|
||||
VectorSubLayerProperties subLayer = PresetSubLayerPropertiesFetcher.GetSubLayerProperties(PresetFeatureType.Roads);
|
||||
subLayer.coreOptions.layerName = dataLayerNameInService;
|
||||
subLayer.coreOptions.sublayerName = assignedSubLayerName;
|
||||
subLayer.lineGeometryOptions.Width = lineWidth;
|
||||
|
||||
AddFeatureSubLayer(subLayer);
|
||||
}
|
||||
public virtual void AddPointFeatureSubLayer(string assignedSubLayerName, string dataLayerNameInService)
|
||||
{
|
||||
VectorSubLayerProperties subLayer = PresetSubLayerPropertiesFetcher.GetSubLayerProperties(PresetFeatureType.Points);
|
||||
subLayer.coreOptions.layerName = dataLayerNameInService;
|
||||
subLayer.coreOptions.sublayerName = assignedSubLayerName;
|
||||
|
||||
AddFeatureSubLayer(subLayer);
|
||||
}
|
||||
public virtual void AddCustomFeatureSubLayer(string assignedSubLayerName, string dataLayerNameInService)
|
||||
{
|
||||
VectorSubLayerProperties subLayer = PresetSubLayerPropertiesFetcher.GetSubLayerProperties(PresetFeatureType.Custom);
|
||||
subLayer.coreOptions.layerName = dataLayerNameInService;
|
||||
subLayer.coreOptions.sublayerName = assignedSubLayerName;
|
||||
|
||||
AddFeatureSubLayer(subLayer);
|
||||
}
|
||||
|
||||
public virtual IEnumerable<VectorSubLayerProperties> GetAllFeatureSubLayers()
|
||||
{
|
||||
return _layerProperty.vectorSubLayers.AsEnumerable();
|
||||
}
|
||||
|
||||
public virtual IEnumerable<VectorSubLayerProperties> GetAllPolygonFeatureSubLayers()
|
||||
{
|
||||
foreach (var featureLayer in _layerProperty.vectorSubLayers)
|
||||
{
|
||||
if (featureLayer.coreOptions.geometryType == VectorPrimitiveType.Polygon)
|
||||
{
|
||||
yield return featureLayer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual IEnumerable<VectorSubLayerProperties> GetAllLineFeatureSubLayers()
|
||||
{
|
||||
foreach (var featureLayer in _layerProperty.vectorSubLayers)
|
||||
{
|
||||
if (featureLayer.coreOptions.geometryType == VectorPrimitiveType.Line)
|
||||
{
|
||||
yield return featureLayer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual IEnumerable<VectorSubLayerProperties> GetAllPointFeatureSubLayers()
|
||||
{
|
||||
foreach (var featureLayer in _layerProperty.vectorSubLayers)
|
||||
{
|
||||
if (featureLayer.coreOptions.geometryType == VectorPrimitiveType.Point)
|
||||
{
|
||||
yield return featureLayer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual IEnumerable<VectorSubLayerProperties> GetFeatureSubLayerByQuery(Func<VectorSubLayerProperties, bool> query)
|
||||
{
|
||||
foreach (var featureLayer in _layerProperty.vectorSubLayers)
|
||||
{
|
||||
if (query(featureLayer))
|
||||
{
|
||||
yield return featureLayer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual VectorSubLayerProperties GetFeatureSubLayerAtIndex(int i)
|
||||
{
|
||||
if (i < _layerProperty.vectorSubLayers.Count)
|
||||
{
|
||||
return _layerProperty.vectorSubLayers[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual VectorSubLayerProperties FindFeatureSubLayerWithName(string featureLayerName)
|
||||
{
|
||||
int foundLayerIndex = -1;
|
||||
// Optimize for performance.
|
||||
for (int i = 0; i < _layerProperty.vectorSubLayers.Count; i++)
|
||||
{
|
||||
if (_layerProperty.vectorSubLayers[i].SubLayerNameMatchesExact(featureLayerName))
|
||||
{
|
||||
foundLayerIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (foundLayerIndex != -1) ? _layerProperty.vectorSubLayers[foundLayerIndex] : null;
|
||||
}
|
||||
|
||||
public virtual void RemoveFeatureSubLayerWithName(string featureLayerName)
|
||||
{
|
||||
var layerToRemove = FindFeatureSubLayerWithName(featureLayerName);
|
||||
if (layerToRemove != null)
|
||||
{
|
||||
//vectorSubLayers.Remove(layerToRemove);
|
||||
_layerProperty.OnSubLayerPropertyRemoved(new VectorLayerUpdateArgs { property = layerToRemove });
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void RemoveFeatureSubLayer(VectorSubLayerProperties layer)
|
||||
{
|
||||
_layerProperty.vectorSubLayers.Remove(layer);
|
||||
_layerProperty.OnSubLayerPropertyRemoved(new VectorLayerUpdateArgs { property = layer });
|
||||
}
|
||||
|
||||
// POI LAYER OPERATIONS
|
||||
|
||||
public virtual void AddPointsOfInterestSubLayer(PrefabItemOptions poiLayerProperties)
|
||||
{
|
||||
if (_layerProperty.locationPrefabList == null)
|
||||
{
|
||||
_layerProperty.locationPrefabList = new List<PrefabItemOptions>();
|
||||
}
|
||||
|
||||
_layerProperty.locationPrefabList.Add(poiLayerProperties);
|
||||
_layerProperty.OnSubLayerPropertyAdded(new VectorLayerUpdateArgs { property = _layerProperty.locationPrefabList.Last() });
|
||||
}
|
||||
|
||||
public virtual IEnumerable<PrefabItemOptions> GetAllPointsOfInterestSubLayers()
|
||||
{
|
||||
return _layerProperty.locationPrefabList.AsEnumerable();
|
||||
}
|
||||
|
||||
public virtual PrefabItemOptions GetPointsOfInterestSubLayerAtIndex(int i)
|
||||
{
|
||||
if (i < _layerProperty.vectorSubLayers.Count)
|
||||
{
|
||||
return _layerProperty.locationPrefabList[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual IEnumerable<PrefabItemOptions> GetPointsOfInterestSubLayerByQuery(Func<PrefabItemOptions, bool> query)
|
||||
{
|
||||
foreach (var poiLayer in _layerProperty.locationPrefabList)
|
||||
{
|
||||
if (query(poiLayer))
|
||||
{
|
||||
yield return poiLayer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual PrefabItemOptions FindPointsofInterestSubLayerWithName(string poiLayerName)
|
||||
{
|
||||
int foundLayerIndex = -1;
|
||||
// Optimize for performance.
|
||||
for (int i = 0; i < _layerProperty.locationPrefabList.Count; i++)
|
||||
{
|
||||
if (_layerProperty.locationPrefabList[i].SubLayerNameMatchesExact(poiLayerName))
|
||||
{
|
||||
foundLayerIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (foundLayerIndex != -1) ? _layerProperty.locationPrefabList[foundLayerIndex] : null;
|
||||
}
|
||||
|
||||
public virtual void RemovePointsOfInterestSubLayerWithName(string poiLayerName)
|
||||
{
|
||||
var layerToRemove = FindPointsofInterestSubLayerWithName(poiLayerName);
|
||||
if (layerToRemove != null)
|
||||
{
|
||||
//vectorSubLayers.Remove(layerToRemove);
|
||||
_layerProperty.OnSubLayerPropertyRemoved(new VectorLayerUpdateArgs { property = layerToRemove });
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void RemovePointsOfInterestSubLayer(PrefabItemOptions layer)
|
||||
{
|
||||
_layerProperty.locationPrefabList.Remove(layer);
|
||||
_layerProperty.OnSubLayerPropertyRemoved(new VectorLayerUpdateArgs { property = layer });
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private helper methods
|
||||
private void SetLayerSourceInternal(VectorSourceType vectorSource)
|
||||
{
|
||||
if (vectorSource != VectorSourceType.Custom && vectorSource != VectorSourceType.None)
|
||||
{
|
||||
_layerProperty.sourceType = vectorSource;
|
||||
_layerProperty.sourceOptions.layerSource = MapboxDefaultVector.GetParameters(vectorSource);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("Invalid style - trying to set " + vectorSource.ToString() + " as default style!");
|
||||
}
|
||||
}
|
||||
private void SetLayerSourceInternal(string vectorSource)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(vectorSource))
|
||||
{
|
||||
_layerProperty.sourceType = VectorSourceType.Custom;
|
||||
_layerProperty.sourceOptions.Id = vectorSource;
|
||||
}
|
||||
else
|
||||
{
|
||||
_layerProperty.sourceType = VectorSourceType.None;
|
||||
Debug.LogWarning("Empty source - turning off vector data. ");
|
||||
}
|
||||
}
|
||||
|
||||
private void SetOptimizedStyleInternal(string styleId, string modifiedDate, string styleName)
|
||||
{
|
||||
_layerProperty.useOptimizedStyle = true;
|
||||
|
||||
_layerProperty.optimizedStyle = _layerProperty.optimizedStyle ?? new Style();
|
||||
|
||||
_layerProperty.optimizedStyle.Id = styleId;
|
||||
_layerProperty.optimizedStyle.Modified = modifiedDate;
|
||||
if (!String.IsNullOrEmpty(styleName))
|
||||
{
|
||||
_layerProperty.optimizedStyle.Name = styleName;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5642fbfe18ab544ca9ff521909205f5f
|
||||
timeCreated: 1519860268
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user