[TASK] Initial commit with basic product setup
This commit is contained in:
74
Assets/Mapbox SDK/Mapbox/Unity/Constants.cs
Normal file
74
Assets/Mapbox SDK/Mapbox/Unity/Constants.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
namespace Mapbox.Unity
|
||||
{
|
||||
using UnityEngine;
|
||||
|
||||
public static class Constants
|
||||
{
|
||||
public const string SDK_VERSION = "2.0.0";
|
||||
|
||||
public static class Path
|
||||
{
|
||||
public const string CONFIG_FILE = "MapboxConfiguration.txt";
|
||||
public const string SCENELIST = "Assets/Mapbox/Resources/Mapbox/ScenesList.asset";
|
||||
public const string SHOULD_COLLECT_LOCATION_KEY = "MAPBOX_SHOULD_COLLECT_LOCATION";
|
||||
public const string TELEMETRY_TURNSTILE_LAST_TICKS_EDITOR_KEY = "MAPBOX_TELEMETRY_TURNSTILE_LAST_TICKS_EDITOR";
|
||||
public const string TELEMETRY_TURNSTILE_LAST_TICKS_FALLBACK_KEY = "MAPBOX_TELEMETRY_TURNSTILE_LAST_TICKS_FALLBACK";
|
||||
public const string DID_PROMPT_CONFIGURATION = "MAPBOX_DID_PROMPT_CONFIGURATION";
|
||||
public static readonly string MAPBOX_RESOURCES_RELATIVE = System.IO.Path.Combine("Mapbox", "MapboxConfiguration");
|
||||
public static readonly string MAPBOX_RESOURCES_ABSOLUTE = System.IO.Path.Combine(System.IO.Path.Combine(Application.dataPath, "Resources"), "Mapbox");
|
||||
|
||||
public static readonly string MAPBOX_USER = System.IO.Path.Combine("Assets", System.IO.Path.Combine("Mapbox", "User"));
|
||||
public static readonly string MAPBOX_USER_MODIFIERS = System.IO.Path.Combine(MAPBOX_USER, "Modifiers");
|
||||
|
||||
public static readonly string MAP_FEATURE_STYLES_DEFAULT_STYLE_ASSETS = System.IO.Path.Combine("MapboxStyles", "DefaultStyleAssets");
|
||||
public static readonly string MAP_FEATURE_STYLES_SAMPLES = System.IO.Path.Combine(System.IO.Path.Combine("MapboxStyles", "Styles"), "MapboxSampleStyles");
|
||||
|
||||
public const string MAPBOX_STYLES_ASSETS_FOLDER = "Assets";
|
||||
public const string MAPBOX_STYLES_ATLAS_FOLDER = "Atlas";
|
||||
public const string MAPBOX_STYLES_MATERIAL_FOLDER = "Materials";
|
||||
public const string MAPBOX_STYLES_PALETTES_FOLDER = "Palettes";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store common vector constants to avoid the method access cost of Unity's convenience getters.
|
||||
/// </summary>
|
||||
public static class Math
|
||||
{
|
||||
public static readonly Vector3 Vector3Zero = new Vector3(0, 0, 0);
|
||||
public static readonly Vector3 Vector3Up = new Vector3(0, 1, 0);
|
||||
public static readonly Vector3 Vector3Down = new Vector3(0, -1, 0);
|
||||
public static readonly Vector3 Vector3One = new Vector3(1, 1, 1);
|
||||
public static readonly Vector3 Vector3Forward = new Vector3(0, 0, 1);
|
||||
|
||||
public static Vector3 Vector3Right = new Vector3(1, 0, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store common style asset prefixes and suffixes to avoid string spelling errors in code.
|
||||
/// </summary>
|
||||
public static class StyleAssetNames
|
||||
{
|
||||
public const string ALTAS_SUFFIX = "AtlasInfo";
|
||||
public const string PALETTE_SUFFIX = "Palette";
|
||||
|
||||
public const string TOP_MATERIAL_SUFFIX = "TopMaterial";
|
||||
public const string SIDE_MATERIAL_SUFFIX = "SideMaterial";
|
||||
}
|
||||
|
||||
public static class GUI
|
||||
{
|
||||
public static class Colors
|
||||
{
|
||||
public static readonly Color EDITOR_TEXT_COLOR = new Color(0.7f, 0.7f, 0.7f);
|
||||
public static readonly Color EDITOR_NOTE_COLOR = new Color(1.0f, 0.8f, 0.0f);
|
||||
}
|
||||
|
||||
public static class Styles
|
||||
{
|
||||
public static readonly GUIStyle EDITOR_NOTE_STYLE = new GUIStyle { wordWrap = true, normal = { textColor = Colors.EDITOR_NOTE_COLOR } };
|
||||
public static readonly GUIStyle EDITOR_TEXTURE_STYLE_DESCRIPTION_STYLE = new GUIStyle { wordWrap = true, normal = { textColor = Colors.EDITOR_TEXT_COLOR } };
|
||||
public static readonly GUIStyle EDITOR_TEXTURE_THUMBNAIL_STYLE = new GUIStyle { imagePosition = ImagePosition.ImageOnly, wordWrap = true };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Assets/Mapbox SDK/Mapbox/Unity/Constants.cs.meta
Normal file
13
Assets/Mapbox SDK/Mapbox/Unity/Constants.cs.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b67e8fe074d514541929f4b6866ff464
|
||||
timeCreated: 1490302604
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Mapbox SDK/Mapbox/Unity/DataContainers.meta
Normal file
8
Assets/Mapbox SDK/Mapbox/Unity/DataContainers.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5add2134655e449d5ae03f7b1a0e42db
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,34 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
[Serializable]
|
||||
public class CameraBoundsTileProviderOptions : ExtentOptions
|
||||
{
|
||||
public Camera camera;
|
||||
public int visibleBuffer;
|
||||
public int disposeBuffer;
|
||||
|
||||
public override void SetOptions(ExtentOptions extentOptions)
|
||||
{
|
||||
CameraBoundsTileProviderOptions options = extentOptions as CameraBoundsTileProviderOptions;
|
||||
if (options != null)
|
||||
{
|
||||
camera = options.camera;
|
||||
visibleBuffer = options.visibleBuffer;
|
||||
disposeBuffer = options.disposeBuffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("ExtentOptions type mismatch : Using " + extentOptions.GetType() + " to set extent of type " + this.GetType());
|
||||
}
|
||||
}
|
||||
|
||||
public void SetOptions(Camera mapCamera, int visibleRange, int disposeRange)
|
||||
{
|
||||
camera = mapCamera;
|
||||
visibleBuffer = visibleRange;
|
||||
disposeBuffer = disposeRange;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2a954ea9b37a847a796dd7c9a9eec9ef
|
||||
timeCreated: 1519860268
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,34 @@
|
||||
using Mapbox.Unity.SourceLayers;
|
||||
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using Mapbox.Unity.MeshGeneration.Modifiers;
|
||||
using System;
|
||||
|
||||
[Serializable]
|
||||
public class ColliderOptions : ModifierProperties, ISubLayerColliderOptions
|
||||
{
|
||||
public override Type ModifierType
|
||||
{
|
||||
get
|
||||
{
|
||||
return typeof(ColliderModifier);
|
||||
}
|
||||
}
|
||||
|
||||
public ColliderType colliderType = ColliderType.None;
|
||||
|
||||
/// <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>
|
||||
public virtual void SetFeatureCollider(ColliderType colType)
|
||||
{
|
||||
if (colliderType != colType)
|
||||
{
|
||||
colliderType = colType;
|
||||
HasChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f38b85c80ace3431c90c6b093436742d
|
||||
timeCreated: 1522459497
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,17 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
[Serializable]
|
||||
public class ElevationModificationOptions
|
||||
{
|
||||
[Tooltip("Mesh resolution of terrain, results in n x n grid")]
|
||||
[Range(2,255)]
|
||||
public int sampleCount = 10;
|
||||
[Tooltip("Use world relative scale to scale terrain height.")]
|
||||
public bool useRelativeHeight = false;
|
||||
[Tooltip("Earth radius in Unity units.")]
|
||||
public float earthRadius = 1000f;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3ea9e2e957a054a95bf8ae23752c1817
|
||||
timeCreated: 1519860268
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,17 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
[Serializable]
|
||||
public class ElevationRequiredOptions : MapboxDataProperty
|
||||
{
|
||||
[Range(0, 100)]
|
||||
[Tooltip("Multiplication factor to vertically exaggerate elevation on terrain, does not work with Flat Terrain.")]
|
||||
public float exaggerationFactor = 1;
|
||||
|
||||
public override bool NeedsForceUpdate()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ec77d5b3f43f8457c96da252d4a01aed
|
||||
timeCreated: 1520011256
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,20 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using UnityEngine;
|
||||
|
||||
public interface ITileProviderOptions
|
||||
{
|
||||
}
|
||||
|
||||
public interface ICameraBoundsExtentOptions : ITileProviderOptions
|
||||
{
|
||||
void SetOptions();
|
||||
}
|
||||
|
||||
public class ExtentOptions : ITileProviderOptions
|
||||
{
|
||||
public virtual void SetOptions(ExtentOptions extentOptions)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e2169b8754ae6418f97dcea8b7ca62e2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,268 @@
|
||||
using Mapbox.Unity.SourceLayers;
|
||||
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using System;
|
||||
using Mapbox.Unity.MeshGeneration.Modifiers;
|
||||
using Mapbox.Unity.MeshGeneration.Data;
|
||||
using UnityEngine;
|
||||
|
||||
[Serializable]
|
||||
public class GeometryExtrusionOptions : ModifierProperties, ISubLayerExtrusionOptions
|
||||
{
|
||||
public override Type ModifierType
|
||||
{
|
||||
get
|
||||
{
|
||||
return typeof(HeightModifier);
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private string _selectedLayerName;
|
||||
public ExtrusionType extrusionType = ExtrusionType.None;
|
||||
public ExtrusionGeometryType extrusionGeometryType = ExtrusionGeometryType.RoofAndSide;
|
||||
[Tooltip("Property name in feature layer to use for extrusion.")]
|
||||
public string propertyName = "height";
|
||||
public string propertyDescription = "";
|
||||
public float minimumHeight = 0f;
|
||||
public float maximumHeight = 0f;
|
||||
[Tooltip("Scale factor to multiply the extrusion value of the feature.")]
|
||||
public float extrusionScaleFactor = 1f;
|
||||
|
||||
public GeometryExtrusionWithAtlasOptions ToGeometryExtrusionWithAtlasOptions()
|
||||
{
|
||||
return new GeometryExtrusionWithAtlasOptions(this);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Disable mesh extrusion for the features in this layer.
|
||||
/// </summary>
|
||||
public virtual void DisableExtrusion()
|
||||
{
|
||||
if (extrusionType != ExtrusionType.None)
|
||||
{
|
||||
extrusionType = ExtrusionType.None;
|
||||
HasChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <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>
|
||||
public virtual void SetAbsoluteHeight(float absoluteHeight)
|
||||
{
|
||||
if (maximumHeight != absoluteHeight)
|
||||
{
|
||||
maximumHeight = absoluteHeight;
|
||||
HasChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <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>
|
||||
public virtual void SetHeightRange(float minHeight, float maxHeight)
|
||||
{
|
||||
if (minimumHeight != minHeight ||
|
||||
maximumHeight != maxHeight)
|
||||
{
|
||||
minimumHeight = minHeight;
|
||||
maximumHeight = maxHeight;
|
||||
HasChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the extrusion multiplier which will be used only in the Y axis (height).
|
||||
/// </summary>
|
||||
/// <param name="multiplier">Multiplier value.</param>
|
||||
public virtual void SetExtrusionMultiplier(float multiplier)
|
||||
{
|
||||
if (extrusionScaleFactor != multiplier)
|
||||
{
|
||||
extrusionScaleFactor = multiplier;
|
||||
HasChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Changes extrusion type to "Absolute height" and extrudes all features by
|
||||
/// the given fixed value.
|
||||
/// </summary>
|
||||
/// <param name="geometryType">Option to create top and side polygons after extrusion.</param>
|
||||
/// <param name="height">Extrusion value</param>
|
||||
/// <param name="scaleFactor">Height multiplier</param>
|
||||
public virtual void EnableAbsoluteExtrusion(ExtrusionGeometryType geometryType, float height, float scaleFactor = 1)
|
||||
{
|
||||
if (extrusionType != ExtrusionType.AbsoluteHeight ||
|
||||
extrusionGeometryType != geometryType ||
|
||||
!Mathf.Approximately(maximumHeight, height) ||
|
||||
!Mathf.Approximately(extrusionScaleFactor, scaleFactor))
|
||||
{
|
||||
extrusionType = ExtrusionType.AbsoluteHeight;
|
||||
extrusionGeometryType = geometryType;
|
||||
maximumHeight = height;
|
||||
extrusionScaleFactor = scaleFactor;
|
||||
HasChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Changes extrusion type to "Property" and extrudes all features by
|
||||
/// the choosen property's value.
|
||||
/// </summary>
|
||||
/// <param name="geometryType">Option to create top and side polygons after extrusion.</param>
|
||||
/// <param name="propertyAttribute">Name of the property to use for extrusion</param>
|
||||
/// <param name="scaleFactor">Height multiplier</param>
|
||||
public virtual void EnablePropertyExtrusion(ExtrusionGeometryType geometryType, string propertyAttribute = "height", float scaleFactor = 1)
|
||||
{
|
||||
if (extrusionType != ExtrusionType.PropertyHeight ||
|
||||
extrusionGeometryType != geometryType ||
|
||||
propertyName != propertyAttribute ||
|
||||
!Mathf.Approximately(extrusionScaleFactor, scaleFactor))
|
||||
{
|
||||
extrusionType = ExtrusionType.PropertyHeight;
|
||||
extrusionGeometryType = geometryType;
|
||||
propertyName = propertyAttribute;
|
||||
extrusionScaleFactor = scaleFactor;
|
||||
HasChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <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>
|
||||
public virtual void EnableMinExtrusion(ExtrusionGeometryType extrusionGeometryType, string propertyName = "height", float extrusionScaleFactor = 1)
|
||||
{
|
||||
if (extrusionType != ExtrusionType.MinHeight ||
|
||||
this.extrusionGeometryType != extrusionGeometryType ||
|
||||
this.propertyName != propertyName ||
|
||||
!Mathf.Approximately(this.extrusionScaleFactor, extrusionScaleFactor))
|
||||
{
|
||||
extrusionType = ExtrusionType.MinHeight;
|
||||
this.extrusionGeometryType = extrusionGeometryType;
|
||||
this.propertyName = propertyName;
|
||||
this.extrusionScaleFactor = extrusionScaleFactor;
|
||||
HasChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <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 ISubLayerExtrusionOptions.EnableMaxExtrusion(ExtrusionGeometryType extrusionGeometryType, string propertyName, float extrusionScaleFactor)
|
||||
{
|
||||
if (extrusionType != ExtrusionType.MaxHeight ||
|
||||
this.extrusionGeometryType != extrusionGeometryType ||
|
||||
this.propertyName != propertyName ||
|
||||
!Mathf.Approximately(this.extrusionScaleFactor, extrusionScaleFactor))
|
||||
{
|
||||
this.extrusionType = ExtrusionType.MaxHeight;
|
||||
this.extrusionGeometryType = extrusionGeometryType;
|
||||
this.propertyName = propertyName;
|
||||
this.extrusionScaleFactor = extrusionScaleFactor;
|
||||
HasChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// /// <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>
|
||||
public virtual void EnableRangeExtrusion(ExtrusionGeometryType extrusionGeometryType, float minHeight, float maxHeight, float extrusionScaleFactor = 1)
|
||||
{
|
||||
if (extrusionType != ExtrusionType.RangeHeight ||
|
||||
this.extrusionGeometryType != extrusionGeometryType ||
|
||||
!Mathf.Approximately(minimumHeight, minHeight) ||
|
||||
!Mathf.Approximately(maximumHeight, maxHeight) ||
|
||||
!Mathf.Approximately(this.extrusionScaleFactor, extrusionScaleFactor))
|
||||
{
|
||||
extrusionType = ExtrusionType.RangeHeight;
|
||||
this.extrusionGeometryType = extrusionGeometryType;
|
||||
minimumHeight = minHeight;
|
||||
maximumHeight = maxHeight;
|
||||
this.extrusionScaleFactor = extrusionScaleFactor;
|
||||
HasChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class GeometryExtrusionWithAtlasOptions : ModifierProperties
|
||||
{
|
||||
public override Type ModifierType
|
||||
{
|
||||
get
|
||||
{
|
||||
return typeof(TextureSideWallModifier);
|
||||
}
|
||||
}
|
||||
public UvMapType texturingType = UvMapType.Tiled;
|
||||
public AtlasInfo atlasInfo;
|
||||
public ExtrusionType extrusionType = ExtrusionType.None;
|
||||
public ExtrusionGeometryType extrusionGeometryType = ExtrusionGeometryType.RoofAndSide;
|
||||
public string propertyName = "height";
|
||||
public string propertyDescription = "";
|
||||
public float minimumHeight = 0f;
|
||||
public float maximumHeight = 0f;
|
||||
public float extrusionScaleFactor = 1f;
|
||||
|
||||
public GeometryExtrusionWithAtlasOptions()
|
||||
{
|
||||
|
||||
}
|
||||
public GeometryExtrusionWithAtlasOptions(GeometryExtrusionOptions extrusionOptions, UVModifierOptions uvOptions)
|
||||
{
|
||||
extrusionType = extrusionOptions.extrusionType;
|
||||
extrusionGeometryType = extrusionOptions.extrusionGeometryType;
|
||||
propertyName = extrusionOptions.propertyName;
|
||||
minimumHeight = extrusionOptions.minimumHeight;
|
||||
maximumHeight = extrusionOptions.maximumHeight;
|
||||
extrusionScaleFactor = extrusionOptions.extrusionScaleFactor;
|
||||
|
||||
texturingType = uvOptions.texturingType;
|
||||
atlasInfo = uvOptions.atlasInfo;
|
||||
}
|
||||
|
||||
public GeometryExtrusionWithAtlasOptions(GeometryExtrusionOptions extrusionOptions)
|
||||
{
|
||||
extrusionType = extrusionOptions.extrusionType;
|
||||
extrusionGeometryType = extrusionOptions.extrusionGeometryType;
|
||||
propertyName = extrusionOptions.propertyName;
|
||||
minimumHeight = extrusionOptions.minimumHeight;
|
||||
maximumHeight = extrusionOptions.maximumHeight;
|
||||
extrusionScaleFactor = extrusionOptions.extrusionScaleFactor;
|
||||
}
|
||||
|
||||
public GeometryExtrusionWithAtlasOptions(UVModifierOptions uvOptions)
|
||||
{
|
||||
texturingType = uvOptions.texturingType;
|
||||
atlasInfo = uvOptions.atlasInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6b1ce30c2116b4d1dadcc0fd64b73d86
|
||||
timeCreated: 1519860268
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,309 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using Mapbox.Unity.MeshGeneration.Modifiers;
|
||||
using Mapbox.Unity.MeshGeneration.Data;
|
||||
|
||||
[Serializable]
|
||||
public class CustomStyleBundle
|
||||
{
|
||||
public UvMapType texturingType = UvMapType.Tiled;
|
||||
public MaterialList[] materials = new MaterialList[2];
|
||||
public AtlasInfo atlasInfo;
|
||||
public ScriptablePalette colorPalette;
|
||||
|
||||
public CustomStyleBundle()
|
||||
{
|
||||
materials = new MaterialList[2];
|
||||
materials[0] = new MaterialList();
|
||||
materials[1] = new MaterialList();
|
||||
|
||||
//SetDefaultAssets();
|
||||
}
|
||||
|
||||
private void AssignAssets(StyleAssetPathBundle styleAssetPathBundle)
|
||||
{
|
||||
Material topMaterial = Resources.Load(styleAssetPathBundle.topMaterialPath, typeof(Material)) as Material;
|
||||
Material sideMaterial = Resources.Load(styleAssetPathBundle.sideMaterialPath, typeof(Material)) as Material;
|
||||
|
||||
AtlasInfo atlas = Resources.Load(styleAssetPathBundle.atlasPath, typeof(AtlasInfo)) as AtlasInfo;
|
||||
ScriptablePalette palette = Resources.Load(styleAssetPathBundle.palettePath, typeof(ScriptablePalette)) as ScriptablePalette;
|
||||
|
||||
materials[0].Materials[0] = new Material(topMaterial);
|
||||
materials[1].Materials[0] = new Material(sideMaterial);
|
||||
atlasInfo = atlas;
|
||||
colorPalette = palette;
|
||||
}
|
||||
|
||||
public void SetDefaultAssets(UvMapType mapType = UvMapType.Atlas)
|
||||
{
|
||||
StyleAssetPathBundle styleAssetPathBundle = new StyleAssetPathBundle("Default", Constants.Path.MAP_FEATURE_STYLES_DEFAULT_STYLE_ASSETS);
|
||||
texturingType = mapType;
|
||||
AssignAssets(styleAssetPathBundle);
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class GeometryMaterialOptions : ModifierProperties, ISubLayerTexturing
|
||||
|
||||
{
|
||||
public override Type ModifierType
|
||||
{
|
||||
get
|
||||
{
|
||||
return typeof(MaterialModifier);
|
||||
}
|
||||
}
|
||||
private SubLayerDarkStyle _darkStyle;
|
||||
public ISubLayerDarkStyle DarkStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_darkStyle == null)
|
||||
{
|
||||
_darkStyle = new SubLayerDarkStyle(this);
|
||||
}
|
||||
return _darkStyle;
|
||||
}
|
||||
}
|
||||
|
||||
private SubLayerLightStyle _lightStyle;
|
||||
public ISubLayerLightStyle LightStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_lightStyle == null)
|
||||
{
|
||||
_lightStyle = new SubLayerLightStyle(this);
|
||||
}
|
||||
return _lightStyle;
|
||||
}
|
||||
}
|
||||
|
||||
private SubLayerColorStyle _colorStyle;
|
||||
public ISubLayerColorStyle ColorStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_colorStyle == null)
|
||||
{
|
||||
_colorStyle = new SubLayerColorStyle(this);
|
||||
}
|
||||
return _colorStyle;
|
||||
}
|
||||
}
|
||||
|
||||
private SubLayerSimpleStyle _simpleStyle;
|
||||
public ISubLayerSimpleStyle SimpleStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_simpleStyle == null)
|
||||
{
|
||||
_simpleStyle = new SubLayerSimpleStyle(this);
|
||||
}
|
||||
return _simpleStyle;
|
||||
}
|
||||
}
|
||||
|
||||
private SubLayerRealisticStyle _realisticStyle;
|
||||
public ISubLayerRealisticStyle RealisticStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_realisticStyle == null)
|
||||
{
|
||||
_realisticStyle = new SubLayerRealisticStyle(this);
|
||||
}
|
||||
return _realisticStyle;
|
||||
}
|
||||
}
|
||||
|
||||
private SubLayerFantasyStyle _fantasyStyle;
|
||||
public ISubLayerFantasyStyle FantasyStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_fantasyStyle == null)
|
||||
{
|
||||
_fantasyStyle = new SubLayerFantasyStyle(this);
|
||||
}
|
||||
return _fantasyStyle;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private SubLayerCustomStyle _customStyle;
|
||||
public ISubLayerCustomStyle CustomStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_customStyle == null)
|
||||
{
|
||||
_customStyle = new SubLayerCustomStyle(this);
|
||||
}
|
||||
return _customStyle;
|
||||
}
|
||||
}
|
||||
|
||||
public StyleTypes style;
|
||||
|
||||
public UvMapType texturingType = UvMapType.Tiled;
|
||||
public MaterialList[] materials = new MaterialList[2];
|
||||
public AtlasInfo atlasInfo;
|
||||
|
||||
public float lightStyleOpacity = 1.0f;
|
||||
public float darkStyleOpacity = 1.0f;
|
||||
|
||||
public Color colorStyleColor = Color.white;
|
||||
|
||||
public SamplePalettes samplePalettes;
|
||||
|
||||
public ScriptablePalette colorPalette;
|
||||
|
||||
[SerializeField]
|
||||
public CustomStyleBundle customStyleOptions;
|
||||
|
||||
public GeometryMaterialOptions()
|
||||
{
|
||||
materials = new MaterialList[2];
|
||||
materials[0] = new MaterialList();
|
||||
materials[1] = new MaterialList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets up default values for GeometryMaterial Options.
|
||||
/// If style is set to Custom, user defined values will be used.
|
||||
/// </summary>
|
||||
public void SetDefaultMaterialOptions()
|
||||
{
|
||||
|
||||
{
|
||||
string styleName = style.ToString();
|
||||
|
||||
if (customStyleOptions == null)
|
||||
{
|
||||
customStyleOptions = new CustomStyleBundle();
|
||||
customStyleOptions.SetDefaultAssets();
|
||||
}
|
||||
if (style == StyleTypes.Custom)
|
||||
{
|
||||
//nothing to do. Use custom settings
|
||||
}
|
||||
else
|
||||
{
|
||||
string samplePaletteName = samplePalettes.ToString();
|
||||
|
||||
string path = Path.Combine(Constants.Path.MAP_FEATURE_STYLES_SAMPLES, Path.Combine(styleName, Constants.Path.MAPBOX_STYLES_ASSETS_FOLDER));
|
||||
|
||||
StyleAssetPathBundle styleAssetPathBundle = new StyleAssetPathBundle(styleName, path, samplePaletteName);
|
||||
|
||||
AssignAssets(styleAssetPathBundle);
|
||||
}
|
||||
|
||||
switch (style)
|
||||
{
|
||||
case StyleTypes.Light:
|
||||
Color lightColor = materials[0].Materials[0].color;
|
||||
lightColor.a = lightStyleOpacity;
|
||||
materials[0].Materials[0].color = lightColor;
|
||||
|
||||
lightColor = materials[1].Materials[0].color;
|
||||
lightColor.a = lightStyleOpacity;
|
||||
materials[1].Materials[0].color = lightColor;
|
||||
break;
|
||||
case StyleTypes.Dark:
|
||||
Color darkColor = materials[0].Materials[0].color;
|
||||
darkColor.a = darkStyleOpacity;
|
||||
materials[0].Materials[0].color = darkColor;
|
||||
|
||||
darkColor = materials[1].Materials[0].color;
|
||||
darkColor.a = darkStyleOpacity;
|
||||
materials[1].Materials[0].color = darkColor;
|
||||
break;
|
||||
case StyleTypes.Color:
|
||||
Color color = colorStyleColor;
|
||||
materials[0].Materials[0].color = color;
|
||||
materials[1].Materials[0].color = color;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (style == StyleTypes.Satellite)
|
||||
{
|
||||
texturingType = UvMapType.Tiled;
|
||||
}
|
||||
else
|
||||
{
|
||||
texturingType = (style != StyleTypes.Custom && style == StyleTypes.Simple) ? UvMapType.AtlasWithColorPalette : UvMapType.Atlas;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void AssignAssets(StyleAssetPathBundle styleAssetPathBundle)
|
||||
{
|
||||
Material topMaterial = Resources.Load(styleAssetPathBundle.topMaterialPath, typeof(Material)) as Material;
|
||||
Material sideMaterial = Resources.Load(styleAssetPathBundle.sideMaterialPath, typeof(Material)) as Material;
|
||||
|
||||
AtlasInfo atlas = Resources.Load(styleAssetPathBundle.atlasPath, typeof(AtlasInfo)) as AtlasInfo;
|
||||
ScriptablePalette palette = Resources.Load(styleAssetPathBundle.palettePath, typeof(ScriptablePalette)) as ScriptablePalette;
|
||||
|
||||
materials[0].Materials[0] = new Material(topMaterial);
|
||||
materials[1].Materials[0] = new Material(sideMaterial);
|
||||
atlasInfo = atlas;
|
||||
colorPalette = palette;
|
||||
}
|
||||
|
||||
public void SetDefaultAssets(UvMapType mapType = UvMapType.Atlas)
|
||||
{
|
||||
StyleAssetPathBundle styleAssetPathBundle = new StyleAssetPathBundle("Default", Constants.Path.MAP_FEATURE_STYLES_DEFAULT_STYLE_ASSETS);
|
||||
texturingType = mapType;
|
||||
AssignAssets(styleAssetPathBundle);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the type of the style.
|
||||
/// </summary>
|
||||
/// <param name="styleType">Style type.</param>
|
||||
public void SetStyleType(StyleTypes styleType)
|
||||
{
|
||||
style = styleType;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type of style used in the layer.
|
||||
/// </summary>
|
||||
/// <returns>The style type.</returns>
|
||||
public virtual StyleTypes GetStyleType()
|
||||
{
|
||||
return style;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class UVModifierOptions : ModifierProperties
|
||||
{
|
||||
public override Type ModifierType
|
||||
{
|
||||
get
|
||||
{
|
||||
return typeof(UvModifier);
|
||||
}
|
||||
}
|
||||
public StyleTypes style;
|
||||
public UvMapType texturingType = UvMapType.Tiled;
|
||||
public AtlasInfo atlasInfo;
|
||||
|
||||
public GeometryExtrusionWithAtlasOptions ToGeometryExtrusionWithAtlasOptions()
|
||||
{
|
||||
return new GeometryExtrusionWithAtlasOptions(this);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 86b7939f38d364d049e29aea11e9652c
|
||||
timeCreated: 1519860268
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,20 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
[Serializable]
|
||||
public class ImageryRasterOptions : MapboxDataProperty
|
||||
{
|
||||
[Tooltip("Use higher resolution Mapbox imagery for retina displays; better visual quality and larger texture sizes.")]
|
||||
public bool useRetina = false;
|
||||
[Tooltip("Use Unity compression for the tile texture.")]
|
||||
public bool useCompression = false;
|
||||
[Tooltip("Use texture with Unity generated mipmaps.")]
|
||||
public bool useMipMap = false;
|
||||
|
||||
public override bool NeedsForceUpdate()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: da8808496e454427ea89228f08bd6f78
|
||||
timeCreated: 1519860268
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,17 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Mapbox.Unity.MeshGeneration.Modifiers;
|
||||
using Mapbox.Unity.Utilities;
|
||||
|
||||
[Serializable]
|
||||
public class LayerModifierOptions
|
||||
{
|
||||
public PositionTargetType moveFeaturePositionTo;
|
||||
[NodeEditorElement("Mesh Modifiers")]
|
||||
public List<MeshModifier> MeshModifiers;
|
||||
[NodeEditorElement("Game Object Modifiers")]
|
||||
public List<GameObjectModifier> GoModifiers;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7ad2d6d13d7344c03aa1317615ba9aea
|
||||
timeCreated: 1519860268
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,25 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
[Serializable]
|
||||
public class LayerPerformanceOptions : MapboxDataProperty
|
||||
{
|
||||
[Tooltip("Enable Coroutines to distribute tile loading using coroutines, reduces the load on the main thread and keeps applications responsive. First load may be slower but subsequent loading will be faster. ")]
|
||||
public bool isEnabled = true;
|
||||
[Tooltip("Number of feature entities to group in one single coroutine call. ")]
|
||||
public int entityPerCoroutine = 20;
|
||||
|
||||
public override bool HasChanged
|
||||
{
|
||||
set
|
||||
{
|
||||
if (value == true)
|
||||
{
|
||||
OnPropertyHasChanged(new VectorLayerUpdateArgs { property = this });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 06b8a4cffda584d2995645a0c0c69bc5
|
||||
timeCreated: 1519860268
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,32 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using System;
|
||||
|
||||
[Serializable]
|
||||
public class Style
|
||||
{
|
||||
public string Name;
|
||||
public string Id;
|
||||
public string Modified;
|
||||
public string UserName;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class LayerSourceOptions
|
||||
{
|
||||
public bool isActive;
|
||||
public Style layerSource;
|
||||
|
||||
public string Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return layerSource.Id;
|
||||
}
|
||||
set
|
||||
{
|
||||
layerSource.Id = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2d109dd8fa7ac4aefa3e2dabac3a3e58
|
||||
timeCreated: 1519860268
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,36 @@
|
||||
using Mapbox.Unity.SourceLayers;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using Mapbox.Unity.MeshGeneration.Modifiers;
|
||||
using System;
|
||||
|
||||
[Serializable]
|
||||
public class LineGeometryOptions : ModifierProperties, ISubLayerLineGeometryOptions
|
||||
{
|
||||
public override Type ModifierType
|
||||
{
|
||||
get
|
||||
{
|
||||
return typeof(LineMeshModifier);
|
||||
}
|
||||
}
|
||||
|
||||
[Tooltip("Width of the line feature.")]
|
||||
public float Width = 1.0f;
|
||||
|
||||
/// <summary>
|
||||
/// Sets the width of the mesh generated for line features.
|
||||
/// </summary>
|
||||
/// <param name="width">Width of the mesh generated for line features.</param>
|
||||
public void SetLineWidth(float width)
|
||||
{
|
||||
if (Width != width)
|
||||
{
|
||||
Width = width;
|
||||
HasChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cfba2df2ab678ce4c9dd019820140980
|
||||
timeCreated: 1522459497
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,72 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public static class LocationPrefabCategoryOptions
|
||||
{
|
||||
|
||||
static LocationPrefabCategoryOptions()
|
||||
{
|
||||
PopulateCategoriesToMakiDictionary();
|
||||
}
|
||||
|
||||
private static Dictionary<LocationPrefabCategories, List<string>> CategoriesToMakiDictionary = new Dictionary<LocationPrefabCategories, List<string>>
|
||||
{
|
||||
{LocationPrefabCategories.ArtsAndEntertainment,new List<string>{"art-gallery", "cinema", "stadium", "museum", "library", "zoo", "music", "theatre", "amusement-park"}},
|
||||
{LocationPrefabCategories.Food,new List<string>{"cafe", "bakery", "fast-food", "grocery", "ice-cream", "restaurant"}},
|
||||
{LocationPrefabCategories.Nightlife,new List<string>{"bar", "beer"}},
|
||||
{LocationPrefabCategories.OutdoorsAndRecreation,new List<string>{"aquarium", "campsite", "attraction", "castle", "cemetery", "dog-park", "drinking-water", "garden", "golf", "monument", "park", "picnic-site", "playground", "swimming"}},
|
||||
{LocationPrefabCategories.Services,new List<string>{"bank", "dentist", "toilet", "veterinary", "pharmacy", "college", "school", "hospital", "place-of-worship", "religious-christian", "religious-jewish", "religious-muslim", "police", "post", "doctor", "fire-station", "information", "town-hall", "prison", "embassy", "fuel", "laundry", "lodging"}},
|
||||
{LocationPrefabCategories.Shops,new List<string>{"alcohol-shop", "clothing-store", "shop"}},
|
||||
{LocationPrefabCategories.Transportation,new List<string>{"bus", "car", "bicycle-share", "bicycle", "airfield", "ferry", "harbor", "heliport"}},
|
||||
};
|
||||
|
||||
private static Dictionary<string, LocationPrefabCategories> MakiToCategoriesDictionary = new Dictionary<string, LocationPrefabCategories>();
|
||||
|
||||
|
||||
//Creates a reverse reference from the CategoriesToMakiDictionary
|
||||
private static void PopulateCategoriesToMakiDictionary ()
|
||||
{
|
||||
foreach(var item in CategoriesToMakiDictionary)
|
||||
{
|
||||
foreach(string makiTag in item.Value)
|
||||
{
|
||||
if (!MakiToCategoriesDictionary.ContainsKey(makiTag))
|
||||
{
|
||||
MakiToCategoriesDictionary.Add(makiTag, item.Key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the maki tags list from a <see cref="LocationPrefabCategories"/> category
|
||||
/// </summary>
|
||||
/// <returns>The list of maki tags from supplied category.</returns>
|
||||
/// <param name="category"><see cref="LocationPrefabCategories"/></param>
|
||||
public static List<string> GetMakiListFromCategory(LocationPrefabCategories category)
|
||||
{
|
||||
List<string> returnList = new List<string>();
|
||||
|
||||
CategoriesToMakiDictionary.TryGetValue(category, out returnList);
|
||||
|
||||
return returnList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="LocationPrefabCategories"/> category that the maki tag belongs to.
|
||||
/// </summary>
|
||||
/// <returns>The <see cref="LocationPrefabCategories"/>category from maki tag.</returns>
|
||||
/// <param name="makiTag">Maki tag</param>
|
||||
public static LocationPrefabCategories GetCategoryFromMakiTag(string makiTag)
|
||||
{
|
||||
LocationPrefabCategories returnCategory;
|
||||
|
||||
if (MakiToCategoriesDictionary.TryGetValue(makiTag, out returnCategory))
|
||||
return returnCategory;
|
||||
|
||||
return LocationPrefabCategories.AnyCategory;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fcad5e29c050446fb8a3d19a42549875
|
||||
timeCreated: 1523660773
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,46 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
[Serializable]
|
||||
public class MapExtentOptions : MapboxDataProperty
|
||||
{
|
||||
public MapExtentType extentType = MapExtentType.CameraBounds;
|
||||
public DefaultMapExtents defaultExtents = new DefaultMapExtents();
|
||||
|
||||
public MapExtentOptions(MapExtentType type)
|
||||
{
|
||||
extentType = type;
|
||||
}
|
||||
|
||||
public ExtentOptions GetTileProviderOptions()
|
||||
{
|
||||
ExtentOptions options = new ExtentOptions();
|
||||
switch (extentType)
|
||||
{
|
||||
case MapExtentType.CameraBounds:
|
||||
options = defaultExtents.cameraBoundsOptions;
|
||||
break;
|
||||
case MapExtentType.RangeAroundCenter:
|
||||
options = defaultExtents.rangeAroundCenterOptions;
|
||||
break;
|
||||
case MapExtentType.RangeAroundTransform:
|
||||
options = defaultExtents.rangeAroundTransformOptions;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return options;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Serializable]
|
||||
public class DefaultMapExtents : MapboxDataProperty
|
||||
{
|
||||
public CameraBoundsTileProviderOptions cameraBoundsOptions = new CameraBoundsTileProviderOptions();
|
||||
public RangeTileProviderOptions rangeAroundCenterOptions = new RangeTileProviderOptions();
|
||||
public RangeAroundTransformTileProviderOptions rangeAroundTransformOptions = new RangeAroundTransformTileProviderOptions();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fe478189bf1ab44ce81a642a8a46a211
|
||||
timeCreated: 1519860268
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,20 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using Mapbox.Unity.Utilities;
|
||||
[Serializable]
|
||||
public class MapLocationOptions : MapboxDataProperty
|
||||
{
|
||||
[Geocode]
|
||||
[Tooltip("The coordinates to build a map around")]
|
||||
public string latitudeLongitude = "0,0";
|
||||
[Range(0, 22)]
|
||||
[Tooltip("The zoom level of the map")]
|
||||
public float zoom = 4.0f;
|
||||
|
||||
//TODO : Add Coordinate conversion class.
|
||||
[NonSerialized]
|
||||
public MapCoordinateSystemType coordinateSystemType = MapCoordinateSystemType.WebMercator;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 53cdeb2ee544b4361845e801728f9950
|
||||
timeCreated: 1519860268
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
16
Assets/Mapbox SDK/Mapbox/Unity/DataContainers/MapOptions.cs
Normal file
16
Assets/Mapbox SDK/Mapbox/Unity/DataContainers/MapOptions.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
[Serializable]
|
||||
public class MapOptions : MapboxDataProperty
|
||||
{
|
||||
public MapLocationOptions locationOptions = new MapLocationOptions();
|
||||
public MapExtentOptions extentOptions = new MapExtentOptions(MapExtentType.RangeAroundCenter);
|
||||
public MapPlacementOptions placementOptions = new MapPlacementOptions();
|
||||
public MapScalingOptions scalingOptions = new MapScalingOptions();
|
||||
[Tooltip("Texture used while tiles are loading.")]
|
||||
public Texture2D loadingTexture = null;
|
||||
public Material tileMaterial = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5d04cfc6bdccb40148fc327eca9fd012
|
||||
timeCreated: 1519860268
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,13 @@
|
||||
using Mapbox.Unity.Map.Interfaces;
|
||||
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using System;
|
||||
[Serializable]
|
||||
public class MapPlacementOptions : MapboxDataProperty
|
||||
{
|
||||
public MapPlacementType placementType = MapPlacementType.AtLocationCenter;
|
||||
public bool snapMapToZero = false;
|
||||
public IMapPlacementStrategy placementStrategy;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c075375ebec1542e9938c24aee596fca
|
||||
timeCreated: 1519860268
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
using Mapbox.Unity.Map.Interfaces;
|
||||
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
[Serializable]
|
||||
public class MapScalingOptions : MapboxDataProperty
|
||||
{
|
||||
public MapScalingType scalingType = MapScalingType.Custom;
|
||||
//public MapUnitType unitType = MapUnitType.meters;
|
||||
[Tooltip("Size of each tile in Unity units.")]
|
||||
public float unityTileSize = 100f;
|
||||
|
||||
public IMapScalingStrategy scalingStrategy;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 854768e662c984068bc22c2607fb9a45
|
||||
timeCreated: 1519860268
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,35 @@
|
||||
using Mapbox.Unity.MeshGeneration.Data;
|
||||
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
public abstract class MapboxDataProperty
|
||||
{
|
||||
public event System.EventHandler PropertyHasChanged;
|
||||
protected virtual void OnPropertyHasChanged(System.EventArgs e)
|
||||
{
|
||||
System.EventHandler handler = PropertyHasChanged;
|
||||
if (handler != null)
|
||||
{
|
||||
handler(this, e);
|
||||
}
|
||||
}
|
||||
public virtual bool HasChanged
|
||||
{
|
||||
set
|
||||
{
|
||||
if (value == true)
|
||||
{
|
||||
OnPropertyHasChanged(null /*Pass args here */);
|
||||
}
|
||||
}
|
||||
}
|
||||
public virtual bool NeedsForceUpdate()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
public virtual void UpdateProperty(UnityTile tile)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d7e99aece91ce4463b09850af8e3df52
|
||||
timeCreated: 1536268482
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
388
Assets/Mapbox SDK/Mapbox/Unity/DataContainers/MapboxEnums.cs
Normal file
388
Assets/Mapbox SDK/Mapbox/Unity/DataContainers/MapboxEnums.cs
Normal file
@@ -0,0 +1,388 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using System.ComponentModel;
|
||||
|
||||
// Map related enums
|
||||
public enum MapPresetType
|
||||
{
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Map with imagery and terrain, used along with a location provider.")]
|
||||
#endif
|
||||
LocationBasedMap,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Map with imagery and terrain and vector data - building,roads and poi's.")]
|
||||
#endif
|
||||
WorldSimulator,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Map with imagery and terrain and vector data, used for AR tabletop scenario.")]
|
||||
#endif
|
||||
ARTableTop,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Map with imagery and terrain and vector data, used for world scale AR scenario.")]
|
||||
#endif
|
||||
ARWorldScale,
|
||||
}
|
||||
|
||||
public enum MapPlacementType
|
||||
{
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Map's root is located at the center of tile containing location specified.")]
|
||||
#endif
|
||||
AtTileCenter,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Map's root is located at the location specified.")]
|
||||
#endif
|
||||
AtLocationCenter
|
||||
}
|
||||
|
||||
public enum MapScalingType
|
||||
{
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Map is rendered at actual scale, unity to mercator conversion factor is ignored. ")]
|
||||
#endif
|
||||
WorldScale,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Map is rendered at the scale defined by unity to mercator conversion factor. ")]
|
||||
#endif
|
||||
Custom
|
||||
}
|
||||
|
||||
public enum MapUnitType
|
||||
{
|
||||
meters,
|
||||
kilometers,
|
||||
miles
|
||||
}
|
||||
|
||||
public enum MapExtentType
|
||||
{
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Map extent defined by the camera's viewport bounds.")]
|
||||
#endif
|
||||
CameraBounds,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Map extent defined by range of tiles around map's center tile.")]
|
||||
#endif
|
||||
RangeAroundCenter,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Map extent defined by range of tiles around a target transform.")]
|
||||
#endif
|
||||
RangeAroundTransform,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Map extent defined by custom tile provider.")]
|
||||
#endif
|
||||
Custom,
|
||||
}
|
||||
|
||||
public enum MapCoordinateSystemType
|
||||
{
|
||||
WebMercator,
|
||||
}
|
||||
|
||||
//Layer related enums.
|
||||
public enum MapLayerType
|
||||
{
|
||||
Imagery,
|
||||
Elevation,
|
||||
Vector
|
||||
}
|
||||
|
||||
public enum VectorPrimitiveType
|
||||
{
|
||||
Point,
|
||||
Line,
|
||||
Polygon,
|
||||
Custom
|
||||
}
|
||||
|
||||
public enum UvMapType
|
||||
{
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Use image texture using tiled UV.")]
|
||||
#endif
|
||||
Tiled = 0,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Use an image texture atlas to define textures for roof & sides of buildings.")]
|
||||
#endif
|
||||
Atlas = 2,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Use an image texture atlas and a color pallete to define textures for roof & sides of buildings.")]
|
||||
#endif
|
||||
AtlasWithColorPalette = 3,
|
||||
}
|
||||
|
||||
public enum ImagerySourceType
|
||||
{
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Mapbox Streets is a comprehensive, general-purpose map that emphasizes accurate, legible styling of road and transit networks")]
|
||||
#endif
|
||||
MapboxStreets,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Mapbox Outdoors is a general-purpose map with curated tilesets and specialized styling tailored to hiking, biking, and the most adventurous use cases.")]
|
||||
#endif
|
||||
MapboxOutdoors,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Mapbox Light and Mapbox Dark are subtle, full-featured maps designed to provide geographic context while highlighting the data on your analytics dashboard, data visualization, or data overlay.")]
|
||||
#endif
|
||||
MapboxDark,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Mapbox Light and Mapbox Dark are subtle, full-featured maps designed to provide geographic context while highlighting the data on your analytics dashboard, data visualization, or data overlay.")]
|
||||
#endif
|
||||
MapboxLight,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Mapbox Satellite is our full global base map that is perfect as a blank canvas or an overlay for your own data.")]
|
||||
#endif
|
||||
MapboxSatellite,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Mapbox Satellite Streets combines our Mapbox Satellite with vector data from Mapbox Streets. The comprehensive set of road, label, and POI information brings clarity and context to the crisp detail in our high-resolution satellite imagery.")]
|
||||
#endif
|
||||
MapboxSatelliteStreet,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Use custom tilesets created using Mapbox studio.")]
|
||||
#endif
|
||||
Custom,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Turn off image rendering.")]
|
||||
#endif
|
||||
None
|
||||
}
|
||||
|
||||
public enum ElevationSourceType
|
||||
{
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Mapbox Terrain provides digital elevation model with worldwide coverage. ")]
|
||||
#endif
|
||||
MapboxTerrain,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Use custom digital elevation model tileset.")]
|
||||
#endif
|
||||
Custom,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Render flat terrain.")]
|
||||
#endif
|
||||
None
|
||||
}
|
||||
|
||||
public enum VectorSourceType
|
||||
{
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Mapbox Streets along with unique identifiers for building features. Combines building footprints that may be in different tiles.")]
|
||||
#endif
|
||||
MapboxStreetsWithBuildingIds,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Mapbox Streets vector tiles are largely based on data from OpenStreetMap, a free & global source of geographic data built by volunteers.")]
|
||||
#endif
|
||||
MapboxStreets,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Use custom tilesets created using Mapbox studio. ")]
|
||||
#endif
|
||||
Custom,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Turn off vector data rendering.")]
|
||||
#endif
|
||||
None
|
||||
}
|
||||
public enum ElevationLayerType
|
||||
{
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Render flat terrain with no elevation.")]
|
||||
#endif
|
||||
FlatTerrain,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Render terrain with elevation from the source specified.")]
|
||||
#endif
|
||||
TerrainWithElevation,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Render low polygon terrain with elevation from the source specified")]
|
||||
#endif
|
||||
LowPolygonTerrain,
|
||||
|
||||
// TODO : Might want to reconsider this option.
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Render terrain with no elevation for a globe.")]
|
||||
#endif
|
||||
GlobeTerrain
|
||||
}
|
||||
|
||||
public enum TileTerrainType
|
||||
{
|
||||
//starting from -1 to match ElevationLayerType
|
||||
None = -1,
|
||||
Flat = 0,
|
||||
Elevated = 1,
|
||||
LowPoly = 2,
|
||||
Globe = 3
|
||||
}
|
||||
|
||||
public enum ExtrusionType
|
||||
{
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("No extrusion.")]
|
||||
#endif
|
||||
None,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Extrude features using the property value.")]
|
||||
#endif
|
||||
PropertyHeight,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Extrude features using the property value. Sets height based on property's minimum height, if height isn't uniform. Results in flat tops.")]
|
||||
#endif
|
||||
MinHeight,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Extrude features using the property value. Sets height based on property's maximum height, if height isn't uniform. Results in flat tops.")]
|
||||
#endif
|
||||
MaxHeight,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Extrude features using the property value. Values are clamped in to min and max values if they are lower or greater than min,max values respectively.")]
|
||||
#endif
|
||||
RangeHeight,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Extrude all features using the fixed value.")]
|
||||
#endif
|
||||
AbsoluteHeight,
|
||||
|
||||
|
||||
}
|
||||
|
||||
public enum ExtrusionGeometryType
|
||||
{
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Extrudes both roof and side wall geometry of the vector feature.")]
|
||||
#endif
|
||||
RoofAndSide,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Extrudes only roof geometry of the vector feature.")]
|
||||
#endif
|
||||
RoofOnly,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Extrudes only side wall geometry of the vector feature.")]
|
||||
#endif
|
||||
SideOnly,
|
||||
}
|
||||
|
||||
public enum ColliderType
|
||||
{
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("No collider.")]
|
||||
#endif
|
||||
None,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Box collider addded to the GameObject.")]
|
||||
#endif
|
||||
BoxCollider,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Mesh collider added to the GameObject.")]
|
||||
#endif
|
||||
MeshCollider,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Sphere collider added to the GameObject.")]
|
||||
#endif
|
||||
SphereCollider,
|
||||
}
|
||||
|
||||
public enum MapFeatureType
|
||||
{
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Building Layer.")]
|
||||
#endif
|
||||
Building,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Road Layer.")]
|
||||
#endif
|
||||
Road,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Parkland Layer.")]
|
||||
#endif
|
||||
Parkland,
|
||||
};
|
||||
|
||||
public enum StyleTypes
|
||||
{
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Custom style.")]
|
||||
#endif
|
||||
Custom,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Simple style combines stylized vector designs with scriptable palettes to create a simple, procedurally colored rendering style.")]
|
||||
#endif
|
||||
Simple,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Light style uses colored materials to create light, greyscale shading for your map.")]
|
||||
#endif
|
||||
Light,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Dark style uses colored materials to create dark, greyscale shading for your map.")]
|
||||
#endif
|
||||
Dark,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Realistic style combines modern, urban designs with physically based rendering materials to help create a contemporary, realistic rendering style.")]
|
||||
#endif
|
||||
Realistic,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Fantasy style combines old world medieval designs with physically based rendering materials to help create a fantasy rendering style.")]
|
||||
#endif
|
||||
Fantasy,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Satellite style uses high-resolution satellite imagery as a texture set. The comprehensive set of road, label, and POI information brings clarity and context to the crisp detail in our high-resolution satellite imagery.")]
|
||||
#endif
|
||||
Satellite,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Color style uses user-defined color and opacity to create colorful, flat shading for your map.")]
|
||||
#endif
|
||||
Color,
|
||||
}
|
||||
|
||||
public enum SamplePalettes
|
||||
{
|
||||
City,
|
||||
Urban,
|
||||
Warm,
|
||||
Cool,
|
||||
Rainbow
|
||||
}
|
||||
|
||||
public enum LocationPrefabFindBy
|
||||
{
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Display points of interest based on a choice of categories")]
|
||||
#endif
|
||||
MapboxCategory,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Display points of interest based on name")]
|
||||
#endif
|
||||
POIName,
|
||||
#if !ENABLE_WINMD_SUPPORT
|
||||
[Description("Display points of interest at specific address or geographical co-ordinates on the map")]
|
||||
#endif
|
||||
AddressOrLatLon,
|
||||
}
|
||||
|
||||
public enum LocationPrefabCategories
|
||||
{
|
||||
None = 0,
|
||||
AnyCategory = ~0,
|
||||
ArtsAndEntertainment = 1 << 0,
|
||||
Food = 1 << 1,
|
||||
Nightlife = 1 << 2,
|
||||
OutdoorsAndRecreation = 1 << 3,
|
||||
Services = 1 << 4,
|
||||
Shops = 1 << 5,
|
||||
Transportation = 1 << 6
|
||||
}
|
||||
|
||||
public enum FeatureProcessingStage
|
||||
{
|
||||
PreProcess,
|
||||
Process,
|
||||
PostProcess
|
||||
}
|
||||
|
||||
public enum PresetFeatureType
|
||||
{
|
||||
Buildings,
|
||||
Roads,
|
||||
Landuse,
|
||||
Points,
|
||||
Custom
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 076cfb625c7cd447089acf2294b1d75e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,31 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
[Serializable]
|
||||
public class RangeAroundTransformTileProviderOptions : ExtentOptions
|
||||
{
|
||||
public Transform targetTransform;
|
||||
public int visibleBuffer;
|
||||
public int disposeBuffer;
|
||||
|
||||
public override void SetOptions(ExtentOptions extentOptions)
|
||||
{
|
||||
RangeAroundTransformTileProviderOptions options = extentOptions as RangeAroundTransformTileProviderOptions;
|
||||
if (options != null)
|
||||
{
|
||||
SetOptions(options.targetTransform, options.visibleBuffer, options.disposeBuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("ExtentOptions type mismatch : Using " + extentOptions.GetType() + " to set extent of type " + this.GetType());
|
||||
}
|
||||
}
|
||||
public void SetOptions(Transform tgtTransform = null, int visibleRange = 1, int disposeRange = 1)
|
||||
{
|
||||
targetTransform = tgtTransform;
|
||||
visibleBuffer = visibleRange;
|
||||
disposeBuffer = disposeRange;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fe9e24e68033f4630b1635d66c71a3cc
|
||||
timeCreated: 1519860268
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,42 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
[Serializable]
|
||||
public class RangeTileProviderOptions : ExtentOptions
|
||||
{
|
||||
[Range(0, 10)]
|
||||
public int west = 1;
|
||||
[Range(0, 10)]
|
||||
public int north = 1;
|
||||
[Range(0, 10)]
|
||||
public int east = 1;
|
||||
[Range(0, 10)]
|
||||
public int south = 1;
|
||||
|
||||
public override void SetOptions(ExtentOptions extentOptions)
|
||||
{
|
||||
RangeTileProviderOptions options = extentOptions as RangeTileProviderOptions;
|
||||
if (options != null)
|
||||
{
|
||||
west = options.west;
|
||||
north = options.north;
|
||||
east = options.east;
|
||||
south = options.south;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("ExtentOptions type mismatch : Using " + extentOptions.GetType() + " to set extent of type " + this.GetType());
|
||||
}
|
||||
}
|
||||
|
||||
public void SetOptions(int northRange = 1, int southRange = 1, int eastRange = 1, int westRange = 1)
|
||||
{
|
||||
west = westRange;
|
||||
north = northRange;
|
||||
east = eastRange;
|
||||
south = southRange;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c619de083ef9446b4b774933701dd923
|
||||
timeCreated: 1519860268
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,26 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Mapbox.Unity.MeshGeneration.Modifiers;
|
||||
using System;
|
||||
using Mapbox.Unity.Map;
|
||||
|
||||
[Serializable]
|
||||
public class SpawnPrefabOptions : ModifierProperties
|
||||
{
|
||||
public override Type ModifierType
|
||||
{
|
||||
get
|
||||
{
|
||||
return typeof(PrefabModifier);
|
||||
}
|
||||
}
|
||||
|
||||
public GameObject prefab;
|
||||
public bool scaleDownWithWorld = true;
|
||||
[NonSerialized]
|
||||
public Action<List<GameObject>> AllPrefabsInstatiated = delegate { };
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ae0dbe1711e344fd9908394c6270d93a
|
||||
timeCreated: 1523916609
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,28 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using System;
|
||||
using Mapbox.Unity.MeshGeneration.Data;
|
||||
using UnityEngine;
|
||||
[Serializable]
|
||||
public class TerrainColliderOptions : MapboxDataProperty
|
||||
{
|
||||
[Tooltip("Add Unity Physics collider to terrain tiles, used for detecting collisions etc.")]
|
||||
public bool addCollider = false;
|
||||
|
||||
public override void UpdateProperty(UnityTile tile)
|
||||
{
|
||||
var existingCollider = tile.Collider;
|
||||
if (addCollider)
|
||||
{
|
||||
if (existingCollider == null)
|
||||
{
|
||||
tile.gameObject.AddComponent<MeshCollider>();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UnityEngine.Object.Destroy(tile.Collider);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5e3e24bd5ee1ac74eb27105f96121ab9
|
||||
timeCreated: 1520011256
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
[Serializable]
|
||||
public class TerrainSideWallOptions
|
||||
{
|
||||
[Tooltip("Adds side walls to terrain meshes, reduces visual artifacts.")]
|
||||
public bool isActive = false;
|
||||
[Tooltip("Height of side walls.")]
|
||||
public float wallHeight = 10;
|
||||
[Tooltip("Unity material to use for side walls.")]
|
||||
public Material wallMaterial;// = Resources.Load("TerrainMaterial", typeof(Material)) as Material;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cd7e5d3c41f4f4894871e76b0d68a448
|
||||
timeCreated: 1519860268
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
190
Assets/Mapbox SDK/Mapbox/Unity/DataContainers/TileJsonData.cs
Normal file
190
Assets/Mapbox SDK/Mapbox/Unity/DataContainers/TileJsonData.cs
Normal file
@@ -0,0 +1,190 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Mapbox.Platform.TilesetTileJSON;
|
||||
using UnityEngine;
|
||||
|
||||
[Serializable]
|
||||
public class TileJsonData
|
||||
{
|
||||
public readonly string commonLayersKey = "(layer found in more than one data source)";
|
||||
public readonly string optionalPropertiesString = "(may not appear across all locations)";
|
||||
/// <summary>
|
||||
/// This boolean is to check if tile JSON data has loaded after the data source has changed
|
||||
/// </summary>
|
||||
public bool tileJSONLoaded = false;
|
||||
|
||||
/// <summary>
|
||||
/// Layer Display Names seen in the editor
|
||||
/// </summary>
|
||||
public List<string> LayerDisplayNames = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// Property Display Names seen in the editor
|
||||
/// </summary>
|
||||
public Dictionary<string, List<string>> PropertyDisplayNames = new Dictionary<string, List<string>>();
|
||||
|
||||
/// <summary>
|
||||
/// The description of the property in a layer
|
||||
/// </summary>
|
||||
public Dictionary<string, Dictionary<string, string>> LayerPropertyDescriptionDictionary = new Dictionary<string, Dictionary<string, string>>();
|
||||
|
||||
/// <summary>
|
||||
/// List of data sources (tileset ids) linked to a layer name
|
||||
/// </summary>
|
||||
public Dictionary<string, List<string>> LayerSourcesDictionary = new Dictionary<string, List<string>>();
|
||||
|
||||
/// <summary>
|
||||
/// Dictionary containting the list of layers in a source
|
||||
/// </summary>
|
||||
public Dictionary<string, List<string>> SourceLayersDictionary = new Dictionary<string, List<string>>();
|
||||
|
||||
public void ClearData()
|
||||
{
|
||||
tileJSONLoaded = false;
|
||||
LayerPropertyDescriptionDictionary.Clear();
|
||||
LayerSourcesDictionary.Clear();
|
||||
SourceLayersDictionary.Clear();
|
||||
LayerDisplayNames.Clear();
|
||||
PropertyDisplayNames.Clear();
|
||||
}
|
||||
|
||||
public void ProcessTileJSONData(TileJSONResponse tjr)
|
||||
{
|
||||
tileJSONLoaded = true;
|
||||
List<string> layerPropertiesList = new List<string>();
|
||||
// Un-comment if required. Throws a warning right now.
|
||||
//List<string> sourceLayersList = new List<string>();
|
||||
|
||||
if (tjr == null || tjr.VectorLayers == null || tjr.VectorLayers.Length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ClearData();
|
||||
|
||||
var propertyName = "";
|
||||
var propertyDescription = "";
|
||||
var layerSource = "";
|
||||
|
||||
foreach (var layer in tjr.VectorLayers)
|
||||
{
|
||||
//load layer names
|
||||
var layerName = layer.Id;
|
||||
layerPropertiesList = new List<string>();
|
||||
layerSource = layer.Source;
|
||||
//if (layer.Fields.Count == 0)
|
||||
//continue;
|
||||
|
||||
//loading layer sources
|
||||
if (LayerSourcesDictionary.ContainsKey(layerName))
|
||||
{
|
||||
LayerSourcesDictionary[layerName].Add(layerSource);
|
||||
}
|
||||
else
|
||||
{
|
||||
LayerSourcesDictionary.Add(layerName, new List<string>() { layerSource });
|
||||
}
|
||||
|
||||
//loading layers to a data source
|
||||
if (SourceLayersDictionary.ContainsKey(layerSource))
|
||||
{
|
||||
List<string> sourceList = new List<string>();
|
||||
LayerSourcesDictionary.TryGetValue(layerName, out sourceList);
|
||||
|
||||
if (sourceList.Count > 1 && sourceList.Contains(layerSource)) // the current layerName has more than one source
|
||||
{
|
||||
if (SourceLayersDictionary.ContainsKey(commonLayersKey))
|
||||
{
|
||||
SourceLayersDictionary[commonLayersKey].Add(layerName);
|
||||
}
|
||||
else
|
||||
{
|
||||
SourceLayersDictionary.Add(commonLayersKey, new List<string>() { layerName });
|
||||
}
|
||||
|
||||
if (LayerDisplayNames.Contains(layerName))
|
||||
{
|
||||
LayerDisplayNames.Remove(layerName);
|
||||
}
|
||||
LayerDisplayNames.Add(layerName);
|
||||
// LayerDisplayNames.Add(layerName + " " + commonLayersKey);
|
||||
}
|
||||
else
|
||||
{
|
||||
SourceLayersDictionary[layerSource].Add(layerName);
|
||||
LayerDisplayNames.Add(layerName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SourceLayersDictionary.Add(layerSource, new List<string>() { layerName });
|
||||
LayerDisplayNames.Add(layerName);
|
||||
}
|
||||
|
||||
|
||||
//Load properties
|
||||
foreach (var property in layer.Fields)
|
||||
{
|
||||
propertyName = property.Key;
|
||||
propertyDescription = property.Value;
|
||||
layerPropertiesList.Add(propertyName);
|
||||
|
||||
//adding property descriptions
|
||||
if (LayerPropertyDescriptionDictionary.ContainsKey(layerName))
|
||||
{
|
||||
if (!LayerPropertyDescriptionDictionary[layerName].ContainsKey(propertyName))
|
||||
{
|
||||
LayerPropertyDescriptionDictionary[layerName].Add(propertyName, propertyDescription);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LayerPropertyDescriptionDictionary.Add(layerName, new Dictionary<string, string>() { { propertyName, propertyDescription } });
|
||||
}
|
||||
|
||||
//Loading display names for properties
|
||||
if (PropertyDisplayNames.ContainsKey(layerName))
|
||||
{
|
||||
if (!PropertyDisplayNames[layerName].Contains(propertyName))
|
||||
{
|
||||
PropertyDisplayNames[layerName].Add(propertyName);
|
||||
|
||||
//logic to add the list of masked properties from all sources that are not #1
|
||||
if (LayerSourcesDictionary[layerName].Count > 1 && !string.IsNullOrEmpty(tjr.Source))
|
||||
{
|
||||
var firstSource = tjr.Source.Split(new string[] { "," }, System.StringSplitOptions.None)[0].Trim();
|
||||
if (layerSource != firstSource)
|
||||
{
|
||||
if (PropertyDisplayNames[layerName].Contains(propertyName))
|
||||
{
|
||||
PropertyDisplayNames[layerName].Remove(propertyName);
|
||||
}
|
||||
|
||||
PropertyDisplayNames[layerName].Add(propertyName);
|
||||
//PropertyDisplayNames[layerName].Add(propertyName + " " + optionalPropertiesString);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PropertyDisplayNames.Add(layerName, new List<string> { propertyName });
|
||||
}
|
||||
}
|
||||
|
||||
if (PropertyDisplayNames.ContainsKey(layerName) && PropertyDisplayNames[layerName].Count > 1)
|
||||
{
|
||||
PropertyDisplayNames[layerName].Sort();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (LayerDisplayNames.Count > 1)
|
||||
{
|
||||
LayerDisplayNames.Sort();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 52cf051b4afa24ba6895b9a42b179eed
|
||||
timeCreated: 1524801966
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
51
Assets/Mapbox SDK/Mapbox/Unity/DataContainers/TileStats.cs
Normal file
51
Assets/Mapbox SDK/Mapbox/Unity/DataContainers/TileStats.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Mapbox.Json;
|
||||
|
||||
public class TileStats
|
||||
{
|
||||
[JsonProperty("account")]
|
||||
public string account;
|
||||
|
||||
[JsonProperty("tilesetid")]
|
||||
public string tilesetid;
|
||||
|
||||
[JsonProperty("layers")]
|
||||
public LayerStats[] layers;
|
||||
}
|
||||
|
||||
public class LayerStats
|
||||
{
|
||||
[JsonProperty("account")]
|
||||
public string account;
|
||||
|
||||
[JsonProperty("tilesetid")]
|
||||
public string tilesetid;
|
||||
|
||||
[JsonProperty("layer")]
|
||||
public string layer;
|
||||
|
||||
[JsonProperty("geometry")]
|
||||
public string geometry;
|
||||
|
||||
[JsonProperty("count")]
|
||||
public string count;
|
||||
|
||||
[JsonProperty("attributes")]
|
||||
public AttributeStats[] attributes;
|
||||
}
|
||||
|
||||
public class AttributeStats
|
||||
{
|
||||
[JsonProperty("attribute")]
|
||||
public string attribute;
|
||||
|
||||
[JsonProperty("type")]
|
||||
public string type;
|
||||
|
||||
[JsonProperty("values")]
|
||||
public string[] values;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a54ae05a24f6b499c8ef1d26ffedbbf6
|
||||
timeCreated: 1530635960
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,50 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using System.IO;
|
||||
using Mapbox.Unity.Map;
|
||||
using UnityEngine;
|
||||
using System.Text;
|
||||
using Mapbox.Json;
|
||||
|
||||
public class TileStatsFetcher
|
||||
{
|
||||
private static TileStatsFetcher _instance;
|
||||
private string _filePath = "Assets/Mapbox/Unity/DataContainers/streets-v7-stats.json";
|
||||
public static TileStatsFetcher Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = new TileStatsFetcher();
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the tile stats json for the supplied source Id.
|
||||
/// </summary>
|
||||
/// <returns>A prepopulated <see cref=" TileStats"/> instance.</returns>
|
||||
/// <param name="sourceId">Source Id of the Mapbox Tileset.</param>
|
||||
public TileStats GetTileStats(VectorSourceType sourceType)
|
||||
{
|
||||
TileStats stats = null;
|
||||
switch (sourceType)
|
||||
{
|
||||
case VectorSourceType.MapboxStreets:
|
||||
case VectorSourceType.MapboxStreetsWithBuildingIds:
|
||||
using (Stream stream = new FileStream(_filePath, FileMode.Open))
|
||||
{
|
||||
using (StreamReader reader = new StreamReader(stream))
|
||||
{
|
||||
stats = JsonConvert.DeserializeObject<TileStats>(reader.ReadToEnd());
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return stats;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7fcfafee1945e413e804e0b0e25ae560
|
||||
timeCreated: 1530635960
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using System;
|
||||
using Mapbox.Unity.Utilities;
|
||||
|
||||
[Serializable]
|
||||
public class UnifiedMapOptions
|
||||
{
|
||||
public MapPresetType mapPreset = MapPresetType.LocationBasedMap;
|
||||
public MapOptions mapOptions = new MapOptions();
|
||||
[NodeEditorElement("Image Layer")]
|
||||
public ImageryLayerProperties imageryLayerProperties = new ImageryLayerProperties();
|
||||
[NodeEditorElement("Terrain Layer")]
|
||||
public ElevationLayerProperties elevationLayerProperties = new ElevationLayerProperties();
|
||||
[NodeEditorElement("Vector Layer")]
|
||||
public VectorLayerProperties vectorLayerProperties = new VectorLayerProperties();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4ee20976ba70747b18ae908f30927ca9
|
||||
timeCreated: 1519860268
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
using Mapbox.Unity.MeshGeneration.Data;
|
||||
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
[Serializable]
|
||||
public class UnityLayerOptions : MapboxDataProperty
|
||||
{
|
||||
[Tooltip("Add terrain tiles to Unity Layer")]
|
||||
public bool addToLayer = false;
|
||||
[Tooltip("Unity Layer id to which terrain tiles will get added.")]
|
||||
public int layerId = 0;
|
||||
|
||||
public override void UpdateProperty(UnityTile tile)
|
||||
{
|
||||
tile.gameObject.layer = layerId;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8ecbb47ee371342fb90233bf8ae8c471
|
||||
timeCreated: 1519860268
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
1855
Assets/Mapbox SDK/Mapbox/Unity/DataContainers/streets-v7-stats.json
Normal file
1855
Assets/Mapbox SDK/Mapbox/Unity/DataContainers/streets-v7-stats.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 575f56052354f4672bed93408ec3e403
|
||||
timeCreated: 1530664790
|
||||
licenseType: Pro
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
10
Assets/Mapbox SDK/Mapbox/Unity/Editor.meta
Normal file
10
Assets/Mapbox SDK/Mapbox/Unity/Editor.meta
Normal file
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7910a23e9d0cc47fc9fb15102d280728
|
||||
folderAsset: yes
|
||||
timeCreated: 1480532369
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,56 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using Mapbox.Unity.MeshGeneration.Modifiers;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
[CustomPropertyDrawer(typeof(AddMonoBehavioursModifierType))]
|
||||
class AddMonoBehavioursModifierDrawer : PropertyDrawer
|
||||
{
|
||||
const int _offset = 40;
|
||||
MonoScript _monoscript;
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
EditorGUI.BeginProperty(position, label, property);
|
||||
|
||||
position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
|
||||
var scriptRect = new Rect(position.x, position.y, position.width, position.height - _offset);
|
||||
var helpRect = new Rect(position.x, position.y + _offset / 2, position.width, _offset);
|
||||
var typeStringProperty = property.FindPropertyRelative("_typeString");
|
||||
var monoscriptProperty = property.FindPropertyRelative("_script");
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
_monoscript = monoscriptProperty.objectReferenceValue as MonoScript;
|
||||
_monoscript = EditorGUI.ObjectField(scriptRect, _monoscript, typeof(MonoScript), false) as MonoScript;
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
var type = _monoscript.GetClass();
|
||||
if (type != null && type.IsSubclassOf(typeof(MonoBehaviour)))
|
||||
{
|
||||
monoscriptProperty.objectReferenceValue = _monoscript;
|
||||
typeStringProperty.stringValue = _monoscript.GetClass().ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
monoscriptProperty.objectReferenceValue = null;
|
||||
typeStringProperty.stringValue = "";
|
||||
}
|
||||
}
|
||||
|
||||
if (monoscriptProperty.objectReferenceValue == null)
|
||||
{
|
||||
EditorGUI.HelpBox(helpRect, "Selected object is not a MonoBehaviour!", MessageType.Error);
|
||||
}
|
||||
|
||||
EditorGUI.EndProperty();
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
return base.GetPropertyHeight(property, label) + _offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 46a3e6ae0815b434c88985c91af9364d
|
||||
timeCreated: 1499902265
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
339
Assets/Mapbox SDK/Mapbox/Unity/Editor/AtlasTemplateGenerator.cs
Normal file
339
Assets/Mapbox SDK/Mapbox/Unity/Editor/AtlasTemplateGenerator.cs
Normal file
@@ -0,0 +1,339 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Mapbox.Unity.MeshGeneration.Data;
|
||||
using System.IO;
|
||||
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
|
||||
class AtlasTemplateGenerator : EditorWindow
|
||||
{
|
||||
[MenuItem("Mapbox/Atlas Template Generator")]
|
||||
public static void ShowWindow()
|
||||
{
|
||||
EditorWindow.GetWindow(typeof(AtlasTemplateGenerator));
|
||||
}
|
||||
|
||||
public class PixelRect
|
||||
{
|
||||
public int x;
|
||||
public int y;
|
||||
|
||||
public int xx;
|
||||
public int yy;
|
||||
}
|
||||
|
||||
public string m_saveFileName = "AtlasTemplate";
|
||||
|
||||
public Texture2D m_texture;
|
||||
|
||||
public AtlasInfo m_atlasInfo;
|
||||
|
||||
public Color[] m_colors;
|
||||
|
||||
public int m_textureResolution = 2048;
|
||||
|
||||
public bool m_generateFacadesTemplate = true;
|
||||
public bool m_generateRoofsTemplate = false;
|
||||
|
||||
private int _drawCount;
|
||||
|
||||
private const int _DEFAULT_TEX_SIZE = 2048;
|
||||
private const int _MIN_TEX_SIZE = 512;
|
||||
private const int _MAX_TEX_SIZE = 2048;
|
||||
|
||||
private const float _cellRatioMargin = 0.01f;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
CreateTexture();
|
||||
}
|
||||
|
||||
private void CreateTexture()
|
||||
{
|
||||
m_texture = new Texture2D(m_textureResolution, m_textureResolution, TextureFormat.ARGB32, false);
|
||||
m_texture.filterMode = FilterMode.Point;
|
||||
}
|
||||
|
||||
void OnGUI()
|
||||
{
|
||||
GUILayout.Space(20);
|
||||
|
||||
GUIStyle titleStyle = new GUIStyle(EditorStyles.label);
|
||||
|
||||
titleStyle.fontSize = 32;
|
||||
titleStyle.normal.textColor = Color.white;
|
||||
titleStyle.fontStyle = FontStyle.Bold;
|
||||
|
||||
titleStyle.stretchWidth = true;
|
||||
titleStyle.stretchHeight = true;
|
||||
|
||||
titleStyle.alignment = TextAnchor.MiddleCenter;
|
||||
|
||||
GUILayout.BeginVertical();
|
||||
|
||||
EditorGUILayout.LabelField("Mapbox Atlas Template Generator", titleStyle, GUILayout.Height(100));
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.BeginVertical(GUILayout.MinWidth(200), GUILayout.MaxWidth(300));
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
m_atlasInfo = EditorGUILayout.ObjectField("Atlas info:", m_atlasInfo, typeof(AtlasInfo), true) as Mapbox.Unity.MeshGeneration.Data.AtlasInfo;
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
m_generateFacadesTemplate = EditorGUILayout.Toggle("Create Facades", m_generateFacadesTemplate);
|
||||
m_generateRoofsTemplate = EditorGUILayout.Toggle("Create Roofs", m_generateRoofsTemplate);
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
if (m_atlasInfo != null)
|
||||
{
|
||||
int facadeCount = m_generateFacadesTemplate ? m_atlasInfo.Textures.Count : 0;
|
||||
int roofCount = m_generateRoofsTemplate ? m_atlasInfo.Roofs.Count : 0;
|
||||
|
||||
int textureCount = facadeCount + roofCount;
|
||||
|
||||
m_colors = new Color[textureCount];
|
||||
|
||||
float hueIncrement = (float)1.0f / textureCount;
|
||||
float hue = 0.0f;
|
||||
|
||||
for (int i = 0; i < textureCount; i++)
|
||||
{
|
||||
m_colors[i] = Color.HSVToRGB(hue, 1.0f, 1.0f);
|
||||
hue += hueIncrement;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_colors = new Color[0];
|
||||
CreateTexture();
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
m_textureResolution = Mathf.Clamp(EditorGUILayout.IntField("Texture resolution:", m_textureResolution), _MIN_TEX_SIZE, _MAX_TEX_SIZE);
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
CreateTexture();
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
if (m_colors != null)
|
||||
{
|
||||
for (int i = 0; i < m_colors.Length; i++)
|
||||
{
|
||||
string colorFieldName = string.Format("Color {0}", i);
|
||||
m_colors[i] = EditorGUILayout.ColorField(colorFieldName, m_colors[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Generate Template"))
|
||||
{
|
||||
if (m_atlasInfo == null)
|
||||
{
|
||||
EditorUtility.DisplayDialog("Atlas Template Generator", "Error: No AtlasInfo object selected.", "Ok");
|
||||
return;
|
||||
}
|
||||
if (!m_generateFacadesTemplate && !m_generateRoofsTemplate)
|
||||
{
|
||||
EditorUtility.DisplayDialog("Atlas Template Generator", "Error: Template generation requires Create Facades and/or Create Roofs to be enabled.", "Ok");
|
||||
return;
|
||||
}
|
||||
GenerateTemplate();
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
if (GUILayout.Button("Save to file"))
|
||||
{
|
||||
SaveTextureAsPNG();
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
|
||||
GUILayout.EndVertical();
|
||||
|
||||
GUIStyle boxStyle = new GUIStyle();
|
||||
|
||||
boxStyle.alignment = TextAnchor.UpperLeft;
|
||||
|
||||
GUILayout.Box(m_texture, boxStyle, GUILayout.Width(300), GUILayout.Height(300), GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.EndVertical();
|
||||
|
||||
GUILayout.Space(20);
|
||||
}
|
||||
|
||||
private int GetPixelCoorFromAtlasRatio(float ratio)
|
||||
{
|
||||
return (int)(m_textureResolution * ratio);
|
||||
}
|
||||
|
||||
private PixelRect ConvertUVRectToPixelRect(Rect atlasRect)
|
||||
{
|
||||
PixelRect pixelRect = new PixelRect();
|
||||
pixelRect.x = GetPixelCoorFromAtlasRatio(atlasRect.x);
|
||||
pixelRect.y = GetPixelCoorFromAtlasRatio(atlasRect.y);
|
||||
pixelRect.xx = GetPixelCoorFromAtlasRatio(atlasRect.x + atlasRect.width);
|
||||
pixelRect.yy = GetPixelCoorFromAtlasRatio(atlasRect.y + atlasRect.height);
|
||||
return pixelRect;
|
||||
}
|
||||
|
||||
private void DrawRect(PixelRect pr, Color color)
|
||||
{
|
||||
for (int i = pr.x; i < pr.xx; i++)
|
||||
{
|
||||
for (int j = pr.y; j < pr.yy; j++)
|
||||
{
|
||||
m_texture.SetPixel(i, j, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawWatermark(int x, int y)
|
||||
{
|
||||
m_texture.SetPixel(x, y, Color.black);
|
||||
m_texture.SetPixel(x + 3, y, Color.black);
|
||||
m_texture.SetPixel(x, y + 3, Color.black);
|
||||
m_texture.SetPixel(x + 3, y + 3, Color.black);
|
||||
|
||||
m_texture.SetPixel(x + 1, y + 1, Color.black);
|
||||
m_texture.SetPixel(x + 2, y + 1, Color.black);
|
||||
m_texture.SetPixel(x + 1, y + 2, Color.black);
|
||||
m_texture.SetPixel(x + 2, y + 2, Color.black);
|
||||
}
|
||||
|
||||
private void DrawCornerWatermarks(PixelRect pr)
|
||||
{
|
||||
DrawWatermark(pr.x, pr.y);
|
||||
DrawWatermark(pr.xx - 4, pr.y);
|
||||
DrawWatermark(pr.x, pr.yy - 4);
|
||||
DrawWatermark(pr.xx - 4, pr.yy - 4);
|
||||
}
|
||||
|
||||
private void DrawDebugCross(PixelRect pr)
|
||||
{
|
||||
int centerX = (pr.x + pr.xx) / 2;
|
||||
int centerY = (pr.y + pr.yy) / 2;
|
||||
|
||||
m_texture.SetPixel(centerX, centerY, Color.black);
|
||||
|
||||
for (int x = pr.x; x < pr.xx; x++)
|
||||
{
|
||||
m_texture.SetPixel(x, centerY, Color.black);
|
||||
m_texture.SetPixel(x, centerY - 1, Color.black);
|
||||
m_texture.SetPixel(x, centerY + 1, Color.black);
|
||||
}
|
||||
|
||||
for (int y = pr.y; y < pr.yy; y++)
|
||||
{
|
||||
m_texture.SetPixel(centerX, y, Color.black);
|
||||
m_texture.SetPixel(centerX - 1, y, Color.black);
|
||||
m_texture.SetPixel(centerX + 1, y, Color.black);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawAtlasEntityData(List<AtlasEntity> aeList)
|
||||
{
|
||||
for (int i = 0; i < aeList.Count; i++)
|
||||
{
|
||||
AtlasEntity ae = aeList[i];
|
||||
|
||||
Rect baseRect = ae.TextureRect;
|
||||
|
||||
float topRatio = ae.TopSectionRatio * baseRect.height;
|
||||
float bottomRatio = ae.BottomSectionRatio * baseRect.height;
|
||||
float middleRatio = baseRect.height - (topRatio + bottomRatio);
|
||||
|
||||
Rect groundFloorRect = new Rect(baseRect.x, baseRect.y, baseRect.width, bottomRatio);
|
||||
Rect topFloorRect = new Rect(baseRect.x, baseRect.y + baseRect.height - topRatio, baseRect.width, topRatio);
|
||||
|
||||
PixelRect basePixelRect = ConvertUVRectToPixelRect(baseRect);
|
||||
PixelRect groundFloorPixelRect = ConvertUVRectToPixelRect(groundFloorRect);
|
||||
PixelRect topFloorPixelRect = ConvertUVRectToPixelRect(topFloorRect);
|
||||
|
||||
Color color = m_colors[_drawCount];
|
||||
Color colorLight = (color + Color.white) / 2;
|
||||
Color colorDark = (color + Color.black) / 2;
|
||||
|
||||
DrawRect(basePixelRect, color);
|
||||
DrawRect(groundFloorPixelRect, colorLight);
|
||||
DrawRect(topFloorPixelRect, colorDark);
|
||||
|
||||
DrawDebugCross(groundFloorPixelRect);
|
||||
DrawDebugCross(topFloorPixelRect);
|
||||
|
||||
int numColumns = (int)ae.ColumnCount;
|
||||
int numMidFloors = ae.MidFloorCount;
|
||||
|
||||
float colWidth = baseRect.width / numColumns;
|
||||
float floorHeight = middleRatio / numMidFloors;
|
||||
|
||||
float midFloorBase = baseRect.y + bottomRatio;
|
||||
|
||||
float mrgn = _cellRatioMargin;
|
||||
float halfMrgn = mrgn / 2;
|
||||
|
||||
for (int j = 0; j < numMidFloors; j++)
|
||||
{
|
||||
float floorStart = midFloorBase + (floorHeight * j);
|
||||
|
||||
for (int k = 0; k < numColumns; k++)
|
||||
{
|
||||
float columnStart = baseRect.x + (colWidth * k);
|
||||
|
||||
Rect cellRect = new Rect(columnStart + halfMrgn, floorStart + halfMrgn, colWidth - mrgn, floorHeight - mrgn);
|
||||
PixelRect cellPixelRect = ConvertUVRectToPixelRect(cellRect);
|
||||
|
||||
DrawRect(cellPixelRect, Color.white);
|
||||
DrawDebugCross(cellPixelRect);
|
||||
}
|
||||
}
|
||||
DrawCornerWatermarks(groundFloorPixelRect);
|
||||
DrawCornerWatermarks(topFloorPixelRect);
|
||||
_drawCount++;
|
||||
}
|
||||
}
|
||||
|
||||
public void GenerateTemplate()
|
||||
{
|
||||
_drawCount = 0;
|
||||
if (m_generateFacadesTemplate)
|
||||
{
|
||||
DrawAtlasEntityData(m_atlasInfo.Textures);
|
||||
}
|
||||
if (m_generateRoofsTemplate)
|
||||
{
|
||||
DrawAtlasEntityData(m_atlasInfo.Roofs);
|
||||
}
|
||||
m_texture.Apply();
|
||||
}
|
||||
|
||||
public void SaveTextureAsPNG()
|
||||
{
|
||||
var path = EditorUtility.SaveFilePanel("Save texture as PNG", "Assets", "AtlasTemplate.png", "png");
|
||||
if (path.Length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
byte[] pngData = m_texture.EncodeToPNG();
|
||||
if (pngData != null)
|
||||
{
|
||||
File.WriteAllBytes(path, pngData);
|
||||
Debug.Log(pngData.Length / 1024 + "Kb was saved as: " + path);
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cc814d64f35ad4f1bbce68318166b67e
|
||||
timeCreated: 1520544854
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
9
Assets/Mapbox SDK/Mapbox/Unity/Editor/Build.meta
Normal file
9
Assets/Mapbox SDK/Mapbox/Unity/Editor/Build.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 28d2b990a838d44e1b28195d8465d645
|
||||
folderAsset: yes
|
||||
timeCreated: 1495491662
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,44 @@
|
||||
#if UNITY_IOS
|
||||
namespace Mapbox.Editor.Build
|
||||
{
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Callbacks;
|
||||
using UnityEditor.iOS.Xcode;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Globalization;
|
||||
|
||||
public class Mapbox_iOS_build : MonoBehaviour
|
||||
{
|
||||
[PostProcessBuild]
|
||||
public static void AppendBuildProperty(BuildTarget buildTarget, string pathToBuiltProject)
|
||||
{
|
||||
if (buildTarget == BuildTarget.iOS)
|
||||
{
|
||||
PBXProject proj = new PBXProject();
|
||||
// path to pbxproj file
|
||||
string projPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj";
|
||||
|
||||
var file = File.ReadAllText(projPath);
|
||||
proj.ReadFromString(file);
|
||||
string target = proj.TargetGuidByName("Unity-iPhone");
|
||||
|
||||
var defaultIncludePath = "Mapbox/Core/Plugins/iOS/MapboxMobileEvents/include";
|
||||
var includePaths = Directory.GetDirectories(Application.dataPath, "include", SearchOption.AllDirectories);
|
||||
var includePath = includePaths
|
||||
.Select(path => Regex.Replace(path, Application.dataPath + "/", ""))
|
||||
.Where(path => path.EndsWith(defaultIncludePath, true, CultureInfo.InvariantCulture))
|
||||
.DefaultIfEmpty(defaultIncludePath)
|
||||
.First();
|
||||
|
||||
proj.AddBuildProperty(target, "HEADER_SEARCH_PATHS", "$(SRCROOT)/Libraries/" + includePath);
|
||||
proj.AddBuildProperty(target, "OTHER_LDFLAGS", "-ObjC -lz");
|
||||
|
||||
File.WriteAllText(projPath, proj.WriteToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4ab2c6d9be5e048179de762cb9bf3cd1
|
||||
timeCreated: 1495323965
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
19
Assets/Mapbox SDK/Mapbox/Unity/Editor/ClearFileCache.cs
Normal file
19
Assets/Mapbox SDK/Mapbox/Unity/Editor/ClearFileCache.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
[InitializeOnLoad]
|
||||
public class ClearFileCache : MonoBehaviour
|
||||
{
|
||||
|
||||
|
||||
[MenuItem("Mapbox/Clear File Cache")]
|
||||
public static void ClearAllCachFiles()
|
||||
{
|
||||
Unity.MapboxAccess.Instance.ClearAllCacheFiles();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
12
Assets/Mapbox SDK/Mapbox/Unity/Editor/ClearFileCache.cs.meta
Normal file
12
Assets/Mapbox SDK/Mapbox/Unity/Editor/ClearFileCache.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 588d3a5d675244fc1a1d927b580b99a3
|
||||
timeCreated: 1497883479
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
245
Assets/Mapbox SDK/Mapbox/Unity/Editor/EditorHelper.cs
Normal file
245
Assets/Mapbox SDK/Mapbox/Unity/Editor/EditorHelper.cs
Normal file
@@ -0,0 +1,245 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Mapbox.Unity.Map;
|
||||
/// <summary>
|
||||
/// EditorHelper class provides methods for working with serialzed properties.
|
||||
/// Methods in this class are based on the spacepuppy-unity-framework, available at the url below.
|
||||
/// https://github.com/lordofduct/spacepuppy-unity-framework/tree/d8d592e212b26cad53264421d22c3d26c6799923/SpacepuppyBaseEditor.
|
||||
/// </summary>
|
||||
public static class EditorHelper
|
||||
{
|
||||
public static void CheckForModifiedProperty<T>(SerializedProperty property, T targetObject, bool forceHasChanged = false)
|
||||
{
|
||||
MapboxDataProperty targetObjectAsDataProperty = GetMapboxDataPropertyObject(targetObject);
|
||||
if (targetObjectAsDataProperty != null)
|
||||
{
|
||||
targetObjectAsDataProperty.HasChanged = forceHasChanged || property.serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
|
||||
public static void CheckForModifiedProperty(SerializedProperty property, bool forceHasChanged = false)
|
||||
{
|
||||
CheckForModifiedProperty(property, GetTargetObjectOfProperty(property), forceHasChanged);
|
||||
}
|
||||
|
||||
public static MapboxDataProperty GetMapboxDataPropertyObject<T>(T targetObject)
|
||||
{
|
||||
return targetObject as MapboxDataProperty;
|
||||
}
|
||||
|
||||
public static bool DidModifyProperty<T>(SerializedProperty property, T targetObject)
|
||||
{
|
||||
MapboxDataProperty targetObjectAsDataProperty = targetObject as MapboxDataProperty;
|
||||
return (property.serializedObject.ApplyModifiedProperties() && targetObjectAsDataProperty != null);
|
||||
}
|
||||
|
||||
public static bool DidModifyProperty(SerializedProperty property)
|
||||
{
|
||||
return DidModifyProperty(property, GetTargetObjectOfProperty(property));
|
||||
}
|
||||
|
||||
public static IEnumerable<SerializedProperty> GetChildren(this SerializedProperty property)
|
||||
{
|
||||
property = property.Copy();
|
||||
var nextElement = property.Copy();
|
||||
bool hasNextElement = nextElement.NextVisible(false);
|
||||
if (!hasNextElement)
|
||||
{
|
||||
nextElement = null;
|
||||
}
|
||||
|
||||
property.NextVisible(true);
|
||||
while (true)
|
||||
{
|
||||
if ((SerializedProperty.EqualContents(property, nextElement)))
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
yield return property;
|
||||
|
||||
bool hasNext = property.NextVisible(false);
|
||||
if (!hasNext)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static System.Type GetTargetType(this SerializedObject obj)
|
||||
{
|
||||
if (obj == null) return null;
|
||||
|
||||
if (obj.isEditingMultipleObjects)
|
||||
{
|
||||
var c = obj.targetObjects[0];
|
||||
return c.GetType();
|
||||
}
|
||||
else
|
||||
{
|
||||
return obj.targetObject.GetType();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the object the property represents.
|
||||
/// </summary>
|
||||
/// <param name="prop"></param>
|
||||
/// <returns></returns>
|
||||
public static object GetTargetObjectOfProperty(SerializedProperty prop)
|
||||
{
|
||||
var path = prop.propertyPath.Replace(".Array.data[", "[");
|
||||
object obj = prop.serializedObject.targetObject;
|
||||
var elements = path.Split('.');
|
||||
foreach (var element in elements)
|
||||
{
|
||||
if (element.Contains("["))
|
||||
{
|
||||
var elementName = element.Substring(0, element.IndexOf("[", StringComparison.CurrentCulture));
|
||||
var index = System.Convert.ToInt32(element.Substring(element.IndexOf("[", StringComparison.CurrentCulture)).Replace("[", "").Replace("]", ""));
|
||||
obj = GetValue_Imp(obj, elementName, index);
|
||||
}
|
||||
else
|
||||
{
|
||||
obj = GetValue_Imp(obj, element);
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
public static void SetTargetObjectOfProperty(SerializedProperty prop, object value)
|
||||
{
|
||||
var path = prop.propertyPath.Replace(".Array.data[", "[");
|
||||
object obj = prop.serializedObject.targetObject;
|
||||
var elements = path.Split('.');
|
||||
foreach (var element in elements.Take(elements.Length - 1))
|
||||
{
|
||||
if (element.Contains("["))
|
||||
{
|
||||
var elementName = element.Substring(0, element.IndexOf("[", StringComparison.CurrentCulture));
|
||||
var index = System.Convert.ToInt32(element.Substring(element.IndexOf("[", StringComparison.CurrentCulture)).Replace("[", "").Replace("]", ""));
|
||||
obj = GetValue_Imp(obj, elementName, index);
|
||||
}
|
||||
else
|
||||
{
|
||||
obj = GetValue_Imp(obj, element);
|
||||
}
|
||||
}
|
||||
|
||||
if (System.Object.ReferenceEquals(obj, null)) return;
|
||||
|
||||
try
|
||||
{
|
||||
var element = elements.Last();
|
||||
|
||||
if (element.Contains("["))
|
||||
{
|
||||
var tp = obj.GetType();
|
||||
var elementName = element.Substring(0, element.IndexOf("[", StringComparison.CurrentCulture));
|
||||
var index = System.Convert.ToInt32(element.Substring(element.IndexOf("[", StringComparison.CurrentCulture)).Replace("[", "").Replace("]", ""));
|
||||
var field = tp.GetField(elementName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
var arr = field.GetValue(obj) as System.Collections.IList;
|
||||
arr[index] = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
var tp = obj.GetType();
|
||||
var field = tp.GetField(element, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
if (field != null)
|
||||
{
|
||||
field.SetValue(obj, value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the object that the property is a member of
|
||||
/// </summary>
|
||||
/// <param name="prop"></param>
|
||||
/// <returns></returns>
|
||||
public static object GetTargetObjectWithProperty(SerializedProperty prop)
|
||||
{
|
||||
var path = prop.propertyPath.Replace(".Array.data[", "[");
|
||||
object obj = prop.serializedObject.targetObject;
|
||||
var elements = path.Split('.');
|
||||
foreach (var element in elements.Take(elements.Length - 1))
|
||||
{
|
||||
if (element.Contains("["))
|
||||
{
|
||||
var elementName = element.Substring(0, element.IndexOf("[", StringComparison.CurrentCulture));
|
||||
var index = System.Convert.ToInt32(element.Substring(element.IndexOf("[", StringComparison.CurrentCulture)).Replace("[", "").Replace("]", ""));
|
||||
obj = GetValue_Imp(obj, elementName, index);
|
||||
}
|
||||
else
|
||||
{
|
||||
obj = GetValue_Imp(obj, element);
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
private static object GetValue_Imp(object source, string name)
|
||||
{
|
||||
if (source == null)
|
||||
return null;
|
||||
var type = source.GetType();
|
||||
|
||||
while (type != null)
|
||||
{
|
||||
var f = type.GetField(name, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
|
||||
if (f != null)
|
||||
return f.GetValue(source);
|
||||
|
||||
var p = type.GetProperty(name, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase);
|
||||
if (p != null)
|
||||
return p.GetValue(source, null);
|
||||
|
||||
type = type.BaseType;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static object GetValue_Imp(object source, string name, int index)
|
||||
{
|
||||
var enumerable = GetValue_Imp(source, name) as System.Collections.IEnumerable;
|
||||
if (enumerable == null) return null;
|
||||
var enm = enumerable.GetEnumerator();
|
||||
|
||||
for (int i = 0; i <= index; i++)
|
||||
{
|
||||
if (!enm.MoveNext()) return null;
|
||||
}
|
||||
return enm.Current;
|
||||
}
|
||||
|
||||
public static int GetChildPropertyCount(SerializedProperty property, bool includeGrandChildren = false)
|
||||
{
|
||||
var pstart = property.Copy();
|
||||
var pend = property.GetEndProperty();
|
||||
int cnt = 0;
|
||||
|
||||
pstart.Next(true);
|
||||
while (!SerializedProperty.EqualContents(pstart, pend))
|
||||
{
|
||||
cnt++;
|
||||
pstart.Next(includeGrandChildren);
|
||||
}
|
||||
|
||||
return cnt;
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Assets/Mapbox SDK/Mapbox/Unity/Editor/EditorHelper.cs.meta
Normal file
13
Assets/Mapbox SDK/Mapbox/Unity/Editor/EditorHelper.cs.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7390a064088424109a975353ccf6e504
|
||||
timeCreated: 1536113196
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
85
Assets/Mapbox SDK/Mapbox/Unity/Editor/FactoryDrawer.cs
Normal file
85
Assets/Mapbox SDK/Mapbox/Unity/Editor/FactoryDrawer.cs
Normal file
@@ -0,0 +1,85 @@
|
||||
//using UnityEngine;
|
||||
//using System.Collections;
|
||||
//using UnityEditor;
|
||||
//using Mapbox.Unity.MeshGeneration.Factories;
|
||||
//using System;
|
||||
//using Mapbox.Unity.MeshGeneration;
|
||||
|
||||
//namespace Mapbox.Editor.NodeEditor
|
||||
//{
|
||||
// [CustomPropertyDrawer(typeof(AssignmentTypeAttribute))]
|
||||
// public class TypeAttributeDrawer : PropertyDrawer
|
||||
// {
|
||||
// float y = 0;
|
||||
|
||||
// public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label)
|
||||
// {
|
||||
// EditorGUI.BeginProperty(position, label, prop);
|
||||
// var att = attribute as AssignmentTypeAttribute;
|
||||
// //var list = prop.FindPropertyRelative("List");
|
||||
// y = position.y;
|
||||
// for (int i = 0; i < prop.arraySize; i++)
|
||||
// {
|
||||
// Rect textFieldPosition = position;
|
||||
// Rect nameRect = new Rect(position.x, y, position.width - 60, 20);
|
||||
// Rect buttonRect = new Rect(position.width - 40, y, 25, 20);
|
||||
|
||||
// GUI.enabled = false;
|
||||
// prop.objectReferenceValue = EditorGUI.ObjectField(nameRect, new GUIContent("Script"), prop.objectReferenceValue, att.Type, false) as ScriptableObject;
|
||||
// GUI.enabled = true;
|
||||
|
||||
// //DrawTextField(nameRect, list.GetArrayElementAtIndex(i), new GUIContent(att.Type.Name));
|
||||
// if (GUI.Button(buttonRect, new GUIContent("E")))
|
||||
// {
|
||||
// Mapbox.Editor.ScriptableCreatorWindow.Open(att.Type, prop);
|
||||
// }
|
||||
// buttonRect = new Rect(position.width - 15, y, 25, 20);
|
||||
// if (GUI.Button(buttonRect, new GUIContent("-")))
|
||||
// {
|
||||
// //prop.DeleteArrayElementAtIndex(i);
|
||||
// }
|
||||
// y += 20;
|
||||
// }
|
||||
|
||||
// Rect buttonRect2 = new Rect(position.x, y, position.width, 20);
|
||||
// if (GUI.Button(buttonRect2, new GUIContent("Add New")))
|
||||
// {
|
||||
// Mapbox.Editor.ScriptableCreatorWindow.Open(att.Type, prop);
|
||||
// }
|
||||
// EditorGUI.EndProperty();
|
||||
// }
|
||||
|
||||
// public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
// {
|
||||
// return base.GetPropertyHeight(property, label);// + property.FindPropertyRelative("List").arraySize * 20 + 10;
|
||||
// }
|
||||
|
||||
// void DrawTextField(Rect position, SerializedProperty prop, GUIContent label)
|
||||
// {
|
||||
// if (prop.objectReferenceValue != null)
|
||||
// {
|
||||
// EditorGUI.BeginChangeCheck();
|
||||
// string value = EditorGUI.TextField(position, label, prop.objectReferenceValue.name + " (" + prop.objectReferenceValue.GetType().Name + ")");
|
||||
// if (EditorGUI.EndChangeCheck())
|
||||
// prop.stringValue = value;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// EditorGUI.BeginChangeCheck();
|
||||
// string value = EditorGUI.TextField(position, label, "Not set");
|
||||
// if (EditorGUI.EndChangeCheck())
|
||||
// prop.stringValue = value;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// public class TypeRAttribute : PropertyAttribute
|
||||
// {
|
||||
// Type type;
|
||||
|
||||
// public TypeRAttribute(Type t)
|
||||
// {
|
||||
// this.type = t;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
12
Assets/Mapbox SDK/Mapbox/Unity/Editor/FactoryDrawer.cs.meta
Normal file
12
Assets/Mapbox SDK/Mapbox/Unity/Editor/FactoryDrawer.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d3e0f99ec9b454e94b7a024c6fe8f743
|
||||
timeCreated: 1504124010
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
13
Assets/Mapbox SDK/Mapbox/Unity/Editor/FactoryEditor.cs
Normal file
13
Assets/Mapbox SDK/Mapbox/Unity/Editor/FactoryEditor.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using UnityEditor;
|
||||
using Mapbox.Unity.MeshGeneration.Factories;
|
||||
|
||||
[CustomEditor(typeof(AbstractTileFactory))]
|
||||
public class FactoryEditor : Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/Mapbox SDK/Mapbox/Unity/Editor/FactoryEditor.cs.meta
Normal file
12
Assets/Mapbox SDK/Mapbox/Unity/Editor/FactoryEditor.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a71b284f467d4de4584d5f813a75c7c0
|
||||
timeCreated: 1490923136
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,27 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using Mapbox.Unity.MeshGeneration.Components;
|
||||
|
||||
[CustomEditor(typeof(FeatureBehaviour))]
|
||||
public class FeatureBehaviourEditor : Editor
|
||||
{
|
||||
FeatureBehaviour _beh;
|
||||
|
||||
public void OnEnable()
|
||||
{
|
||||
_beh = (FeatureBehaviour)target;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
DrawDefaultInspector();
|
||||
|
||||
if (GUILayout.Button("Show Properties"))
|
||||
{
|
||||
_beh.ShowDebugData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 54536e5537a66a842818be9fc7a7d6f3
|
||||
timeCreated: 1499870444
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,71 @@
|
||||
using System;
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using UnityEditor;
|
||||
using UnityEditor.IMGUI.Controls;
|
||||
using UnityEngine;
|
||||
internal class FeatureSectionMultiColumnHeader : MultiColumnHeader
|
||||
{
|
||||
Mode m_Mode;
|
||||
|
||||
public enum Mode
|
||||
{
|
||||
LargeHeader,
|
||||
DefaultHeader,
|
||||
MinimumHeaderWithoutSorting
|
||||
}
|
||||
|
||||
public FeatureSectionMultiColumnHeader(MultiColumnHeaderState state)
|
||||
: base(state)
|
||||
{
|
||||
mode = Mode.DefaultHeader;
|
||||
}
|
||||
|
||||
public Mode mode
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Mode;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_Mode = value;
|
||||
switch (m_Mode)
|
||||
{
|
||||
case Mode.LargeHeader:
|
||||
canSort = true;
|
||||
height = 37f;
|
||||
break;
|
||||
case Mode.DefaultHeader:
|
||||
canSort = true;
|
||||
height = DefaultGUI.defaultHeight;
|
||||
break;
|
||||
case Mode.MinimumHeaderWithoutSorting:
|
||||
canSort = false;
|
||||
height = DefaultGUI.minimumHeight;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void ColumnHeaderGUI(MultiColumnHeaderState.Column column, Rect headerRect, int columnIndex)
|
||||
{
|
||||
// Default column header gui
|
||||
base.ColumnHeaderGUI(column, headerRect, columnIndex);
|
||||
|
||||
// Add additional info for large header
|
||||
if (mode == Mode.LargeHeader)
|
||||
{
|
||||
// Show example overlay stuff on some of the columns
|
||||
if (columnIndex > 2)
|
||||
{
|
||||
headerRect.xMax -= 3f;
|
||||
var oldAlignment = EditorStyles.largeLabel.alignment;
|
||||
EditorStyles.largeLabel.alignment = TextAnchor.UpperRight;
|
||||
GUI.Label(headerRect, 36 + columnIndex + "%", EditorStyles.largeLabel);
|
||||
EditorStyles.largeLabel.alignment = oldAlignment;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 07bf8462a630d4aad95ad6e2fb8b2923
|
||||
timeCreated: 1530231284
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
196
Assets/Mapbox SDK/Mapbox/Unity/Editor/FeatureSubLayerTreeView.cs
Normal file
196
Assets/Mapbox SDK/Mapbox/Unity/Editor/FeatureSubLayerTreeView.cs
Normal file
@@ -0,0 +1,196 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor.IMGUI.Controls;
|
||||
using UnityEditor;
|
||||
using Mapbox.Unity.Map;
|
||||
|
||||
internal class FeatureSubLayerTreeView : TreeViewWithTreeModel<FeatureTreeElement>
|
||||
{
|
||||
public SerializedProperty Layers;
|
||||
private float kToggleWidth = 18f;
|
||||
public int uniqueId;
|
||||
public static int uniqueIdPoI = 1000;
|
||||
public static int uniqueIdFeature = 3000;
|
||||
public int maxElementsAdded = 0;
|
||||
|
||||
public bool hasChanged = false;
|
||||
|
||||
const float kRowHeights = 15f;
|
||||
const float nameOffset = 15f;
|
||||
|
||||
MultiColumnHeaderState m_MultiColumnHeaderState;
|
||||
private GUIStyle columnStyle = new GUIStyle()
|
||||
{
|
||||
alignment = TextAnchor.MiddleCenter,
|
||||
normal = new GUIStyleState() { textColor = Color.white }
|
||||
};
|
||||
|
||||
public FeatureSubLayerTreeView(TreeViewState state, MultiColumnHeader multicolumnHeader, TreeModel<FeatureTreeElement> model, int uniqueIdentifier = 3000) : base(state, multicolumnHeader, model)
|
||||
{
|
||||
// Custom setup
|
||||
//rowHeight = kRowHeights;
|
||||
showAlternatingRowBackgrounds = true;
|
||||
showBorder = true;
|
||||
customFoldoutYOffset = (kRowHeights - EditorGUIUtility.singleLineHeight) * 0.5f; // center foldout in the row since we also center content. See RowGUI
|
||||
extraSpaceBeforeIconAndLabel = kToggleWidth;
|
||||
uniqueId = uniqueIdentifier;
|
||||
Reload();
|
||||
}
|
||||
|
||||
protected override bool CanRename(TreeViewItem item)
|
||||
{
|
||||
// Only allow rename if we can show the rename overlay with a certain width (label might be clipped by other columns)
|
||||
Rect renameRect = GetRenameRect(treeViewRect, 0, item);
|
||||
return renameRect.width > 30;
|
||||
}
|
||||
|
||||
protected override void RenameEnded(RenameEndedArgs args)
|
||||
{
|
||||
if (Layers == null || Layers.arraySize == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.acceptedRename)
|
||||
{
|
||||
var element = treeModel.Find(args.itemID);
|
||||
element.name = string.IsNullOrEmpty(args.newName.Trim()) ? args.originalName : args.newName;
|
||||
element.Name = string.IsNullOrEmpty(args.newName.Trim()) ? args.originalName : args.newName;
|
||||
var layer = Layers.GetArrayElementAtIndex(args.itemID - uniqueId);
|
||||
layer.FindPropertyRelative("coreOptions.sublayerName").stringValue = element.name;
|
||||
Reload();
|
||||
}
|
||||
}
|
||||
|
||||
protected override Rect GetRenameRect(Rect rowRect, int row, TreeViewItem item)
|
||||
{
|
||||
Rect cellRect = GetCellRectForTreeFoldouts(rowRect);
|
||||
cellRect.xMin = nameOffset;
|
||||
CenterRectUsingSingleLineHeight(ref cellRect);
|
||||
return base.GetRenameRect(cellRect, row, item);
|
||||
}
|
||||
|
||||
public void RemoveItemFromTree(int id)
|
||||
{
|
||||
treeModel.RemoveElements(new List<int>() { id });
|
||||
}
|
||||
|
||||
public void AddElementToTree(SerializedProperty subLayer)
|
||||
{
|
||||
var name = subLayer.FindPropertyRelative("coreOptions.sublayerName").stringValue;
|
||||
var id = Layers.arraySize - 1 + uniqueId;
|
||||
|
||||
if (treeModel.Find(id) != null)
|
||||
{
|
||||
Debug.Log(" found one. exiting");
|
||||
return;
|
||||
}
|
||||
|
||||
var type = ((PresetFeatureType)subLayer.FindPropertyRelative("presetFeatureType").enumValueIndex).ToString();
|
||||
FeatureTreeElement element = new FeatureTreeElement(name, 0, id);
|
||||
element.Name = name;
|
||||
element.Type = type;
|
||||
treeModel.AddElement(element, treeModel.root, treeModel.numberOfDataElements - 1);
|
||||
}
|
||||
|
||||
protected override void RowGUI(RowGUIArgs args)
|
||||
{
|
||||
var rowItem = (TreeViewItem<FeatureTreeElement>)args.item;
|
||||
for (int i = 0; i < args.GetNumVisibleColumns(); ++i)
|
||||
{
|
||||
CellGUI(args.GetCellRect(i), rowItem, (FeatureSubLayerColumns)args.GetColumn(i), ref args);
|
||||
}
|
||||
}
|
||||
|
||||
void CellGUI(Rect cellRect, TreeViewItem<FeatureTreeElement> item, FeatureSubLayerColumns column, ref RowGUIArgs args)
|
||||
{
|
||||
// Center cell rect vertically (makes it easier to place controls, icons etc in the cells)
|
||||
if (Layers == null || Layers.arraySize == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Layers.arraySize <= args.item.id - uniqueId)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var layer = Layers.GetArrayElementAtIndex(args.item.id - uniqueId);
|
||||
CenterRectUsingSingleLineHeight(ref cellRect);
|
||||
if (column == FeatureSubLayerColumns.Name)
|
||||
{
|
||||
Rect toggleRect = cellRect;
|
||||
toggleRect.x += GetContentIndent(item);
|
||||
toggleRect.width = kToggleWidth;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
item.data.isActive = layer.FindPropertyRelative("coreOptions.isActive").boolValue;
|
||||
if (toggleRect.xMax < cellRect.xMax)
|
||||
{
|
||||
item.data.isActive = EditorGUI.Toggle(toggleRect, item.data.isActive); // hide when outside cell rect
|
||||
}
|
||||
layer.FindPropertyRelative("coreOptions.isActive").boolValue = item.data.isActive;
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
VectorSubLayerProperties vectorSubLayerProperties = (VectorSubLayerProperties)EditorHelper.GetTargetObjectOfProperty(layer);
|
||||
EditorHelper.CheckForModifiedProperty(layer, vectorSubLayerProperties.coreOptions);
|
||||
}
|
||||
|
||||
cellRect.xMin += nameOffset; // Adding some gap between the checkbox and the name
|
||||
args.rowRect = cellRect;
|
||||
|
||||
layer.FindPropertyRelative("coreOptions.sublayerName").stringValue = item.data.Name;
|
||||
//This draws the name property
|
||||
base.RowGUI(args);
|
||||
}
|
||||
if (column == FeatureSubLayerColumns.Type)
|
||||
{
|
||||
cellRect.xMin += 15f; // Adding some gap between the checkbox and the name
|
||||
|
||||
var typeString = ((PresetFeatureType)layer.FindPropertyRelative("presetFeatureType").intValue).ToString();
|
||||
item.data.Type = typeString;
|
||||
EditorGUI.LabelField(cellRect, item.data.Type, columnStyle);
|
||||
}
|
||||
}
|
||||
|
||||
// All columns
|
||||
enum FeatureSubLayerColumns
|
||||
{
|
||||
Name,
|
||||
Type
|
||||
}
|
||||
|
||||
public static MultiColumnHeaderState CreateDefaultMultiColumnHeaderState()
|
||||
{
|
||||
var columns = new[]
|
||||
{
|
||||
//Name column
|
||||
new MultiColumnHeaderState.Column
|
||||
{
|
||||
headerContent = new GUIContent("Name"),
|
||||
contextMenuText = "Name",
|
||||
headerTextAlignment = TextAlignment.Center,
|
||||
autoResize = true,
|
||||
canSort = false,
|
||||
allowToggleVisibility = false,
|
||||
},
|
||||
|
||||
//Type column
|
||||
new MultiColumnHeaderState.Column
|
||||
{
|
||||
headerContent = new GUIContent("Type"),
|
||||
contextMenuText = "Type",
|
||||
headerTextAlignment = TextAlignment.Center,
|
||||
autoResize = true,
|
||||
canSort = false,
|
||||
allowToggleVisibility = false
|
||||
}
|
||||
};
|
||||
|
||||
var state = new MultiColumnHeaderState(columns);
|
||||
return state;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6959c2320c56c4d89be4ff0e9d2a1b73
|
||||
timeCreated: 1525818947
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
18
Assets/Mapbox SDK/Mapbox/Unity/Editor/FeatureTreeElement.cs
Normal file
18
Assets/Mapbox SDK/Mapbox/Unity/Editor/FeatureTreeElement.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
[Serializable]
|
||||
public class FeatureTreeElement : TreeElement
|
||||
{
|
||||
public string Name;
|
||||
public string Type;
|
||||
public bool isActive;
|
||||
|
||||
public FeatureTreeElement(string name, int depth, int id) : base(name, depth, id)
|
||||
{
|
||||
isActive = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e5ff51a6bc84040388ff12a051e5a758
|
||||
timeCreated: 1530231284
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,34 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using Mapbox.Unity.Utilities;
|
||||
using Mapbox.Unity.Map;
|
||||
|
||||
/// <summary>
|
||||
/// Custom property drawer for geocodes <para/>
|
||||
/// Includes a search window to enable search of Lat/Lon via geocoder.
|
||||
/// Requires a Mapbox token be set for the project
|
||||
/// </summary>
|
||||
[CustomPropertyDrawer(typeof(GeocodeAttribute))]
|
||||
public class GeocodeAttributeDrawer : PropertyDrawer
|
||||
{
|
||||
const string searchButtonContent = "Search";
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
float buttonWidth = EditorGUIUtility.singleLineHeight * 4;
|
||||
|
||||
Rect fieldRect = new Rect(position.x, position.y, position.width - buttonWidth, EditorGUIUtility.singleLineHeight);
|
||||
Rect buttonRect = new Rect(position.x + position.width - buttonWidth, position.y, buttonWidth, EditorGUIUtility.singleLineHeight);
|
||||
|
||||
EditorGUI.PropertyField(fieldRect, property);
|
||||
|
||||
if (GUI.Button(buttonRect, searchButtonContent))
|
||||
{
|
||||
object objectToUpdate = EditorHelper.GetTargetObjectWithProperty(property);
|
||||
GeocodeAttributeSearchWindow.Open(property, objectToUpdate);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 860c0aa37e7b91f49be4dbfdeb25951f
|
||||
timeCreated: 1484134996
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,192 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Mapbox.Geocoding;
|
||||
using Mapbox.Unity;
|
||||
using System.Globalization;
|
||||
using Mapbox.Unity.Map;
|
||||
using Mapbox.Editor;
|
||||
|
||||
public class GeocodeAttributeSearchWindow : EditorWindow
|
||||
{
|
||||
SerializedProperty _coordinateProperty;
|
||||
object _objectToUpdate;
|
||||
|
||||
private bool _updateAbstractMap;
|
||||
|
||||
string _searchInput = "";
|
||||
|
||||
ForwardGeocodeResource _resource;
|
||||
|
||||
List<Feature> _features;
|
||||
|
||||
System.Action<string> _callback;
|
||||
|
||||
const string searchFieldName = "searchField";
|
||||
const float width = 320f;
|
||||
const float height = 300f;
|
||||
|
||||
bool _isSearching = false;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
_resource = new ForwardGeocodeResource("");
|
||||
EditorApplication.playModeStateChanged += OnModeChanged;
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
EditorApplication.playModeStateChanged -= OnModeChanged;
|
||||
}
|
||||
|
||||
bool hasSetFocus = false;
|
||||
|
||||
public static void Open(SerializedProperty property, object objectToUpdate = null)
|
||||
{
|
||||
GeocodeAttributeSearchWindow window = EditorWindow.GetWindow<GeocodeAttributeSearchWindow>(true, "Search for location");
|
||||
|
||||
window._coordinateProperty = property;
|
||||
if (objectToUpdate != null)
|
||||
{
|
||||
window._objectToUpdate = objectToUpdate;
|
||||
}
|
||||
|
||||
Event e = Event.current;
|
||||
Vector2 mousePos = GUIUtility.GUIToScreenPoint(e.mousePosition);
|
||||
|
||||
window.position = new Rect(mousePos.x - width, mousePos.y, width, height);
|
||||
}
|
||||
|
||||
void OnModeChanged(PlayModeStateChange state)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
void OnGUI()
|
||||
{
|
||||
GUILayout.Label("Search for a location");
|
||||
|
||||
string oldSearchInput = _searchInput;
|
||||
|
||||
GUI.SetNextControlName(searchFieldName);
|
||||
_searchInput = GUILayout.TextField(_searchInput);
|
||||
|
||||
if (_searchInput.Length == 0)
|
||||
{
|
||||
GUILayout.Label("Type in a location to find it's latitude and longtitude");
|
||||
}
|
||||
else
|
||||
{
|
||||
bool changed = oldSearchInput != _searchInput;
|
||||
if (changed)
|
||||
{
|
||||
HandleUserInput(_searchInput);
|
||||
}
|
||||
|
||||
if (_features.Count > 0)
|
||||
{
|
||||
GUILayout.Label("Results:");
|
||||
for (int i = 0; i < _features.Count; i++)
|
||||
{
|
||||
Feature feature = _features[i];
|
||||
string coordinates = feature.Center.x.ToString(CultureInfo.InvariantCulture) + ", " +
|
||||
feature.Center.y.ToString(CultureInfo.InvariantCulture);
|
||||
|
||||
//abreviated coords for display in the UI
|
||||
string truncatedCoordinates = feature.Center.x.ToString("F2", CultureInfo.InvariantCulture) + ", " +
|
||||
feature.Center.y.ToString("F2", CultureInfo.InvariantCulture);
|
||||
|
||||
//split feature name and add elements until the maxButtonContentLenght is exceeded
|
||||
string[] featureNameSplit = feature.PlaceName.Split(',');
|
||||
string buttonContent = "";
|
||||
int maxButtonContentLength = 30;
|
||||
for (int j = 0; j < featureNameSplit.Length; j++)
|
||||
{
|
||||
if(buttonContent.Length + featureNameSplit[j].Length < maxButtonContentLength)
|
||||
{
|
||||
if(String.IsNullOrEmpty(buttonContent))
|
||||
{
|
||||
buttonContent = featureNameSplit[j];
|
||||
}
|
||||
else
|
||||
{
|
||||
buttonContent = buttonContent + "," + featureNameSplit[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (buttonContent.Length < maxButtonContentLength + 15)
|
||||
{
|
||||
buttonContent = buttonContent + "," + " (" + truncatedCoordinates + ")";
|
||||
}
|
||||
|
||||
|
||||
if (GUILayout.Button(buttonContent))
|
||||
{
|
||||
_coordinateProperty.stringValue = coordinates;
|
||||
_coordinateProperty.serializedObject.ApplyModifiedProperties();
|
||||
EditorUtility.SetDirty(_coordinateProperty.serializedObject.targetObject);
|
||||
|
||||
if(_objectToUpdate != null)
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(_coordinateProperty, _objectToUpdate, true);
|
||||
}
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_isSearching)
|
||||
GUILayout.Label("Searching...");
|
||||
else
|
||||
GUILayout.Label("No search results");
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasSetFocus)
|
||||
{
|
||||
GUI.FocusControl(searchFieldName);
|
||||
hasSetFocus = true;
|
||||
}
|
||||
}
|
||||
|
||||
void HandleUserInput(string searchString)
|
||||
{
|
||||
_features = new List<Feature>();
|
||||
_isSearching = true;
|
||||
|
||||
if (!string.IsNullOrEmpty(searchString))
|
||||
{
|
||||
_resource.Query = searchString;
|
||||
MapboxAccess.Instance.Geocoder.Geocode(_resource, HandleGeocoderResponse);
|
||||
}
|
||||
}
|
||||
|
||||
void HandleGeocoderResponse(ForwardGeocodeResponse res)
|
||||
{
|
||||
//null if no internet connection
|
||||
if (res != null)
|
||||
{
|
||||
//null if invalid token
|
||||
if (res.Features != null)
|
||||
{
|
||||
_features = res.Features;
|
||||
}
|
||||
}
|
||||
_isSearching = false;
|
||||
this.Repaint();
|
||||
|
||||
//_hasResponse = true;
|
||||
//_coordinate = res.Features[0].Center;
|
||||
//Response = res;
|
||||
//if (OnGeocoderResponse != null)
|
||||
//{
|
||||
// OnGeocoderResponse(this, EventArgs.Empty);
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d99190dd95ea8a245ba1f7c8c3084d0a
|
||||
timeCreated: 1484136312
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
33
Assets/Mapbox SDK/Mapbox/Unity/Editor/LayerModifierEditor.cs
Normal file
33
Assets/Mapbox SDK/Mapbox/Unity/Editor/LayerModifierEditor.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using Mapbox.Unity.MeshGeneration.Modifiers;
|
||||
|
||||
[CustomEditor(typeof(LayerModifier))]
|
||||
public class LayerModifierEditor : Editor
|
||||
{
|
||||
public SerializedProperty layerId_Prop;
|
||||
private MonoScript script;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
layerId_Prop = serializedObject.FindProperty("_layerId");
|
||||
|
||||
script = MonoScript.FromScriptableObject((LayerModifier)target);
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
GUI.enabled = false;
|
||||
script = EditorGUILayout.ObjectField("Script", script, typeof(MonoScript), false) as MonoScript;
|
||||
GUI.enabled = true;
|
||||
|
||||
layerId_Prop.intValue = EditorGUILayout.LayerField("Layer", layerId_Prop.intValue);
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ae3383f13b58e544ba5c12293fff5957
|
||||
timeCreated: 1494349684
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,35 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using Mapbox.Unity.MeshGeneration.Factories;
|
||||
|
||||
[CustomEditor(typeof(MapImageFactory))]
|
||||
public class MapImageFactoryEditor : FactoryEditor
|
||||
{
|
||||
public SerializedProperty layerProperties;
|
||||
private MonoScript script;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
layerProperties = serializedObject.FindProperty("_properties");
|
||||
script = MonoScript.FromScriptableObject((MapImageFactory)target);
|
||||
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
GUI.enabled = false;
|
||||
script = EditorGUILayout.ObjectField("Script", script, typeof(MonoScript), false) as MonoScript;
|
||||
GUI.enabled = true;
|
||||
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.PropertyField(layerProperties);
|
||||
EditorGUILayout.Space();
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 26b414693cf1ad341bd50344ab4198f8
|
||||
timeCreated: 1490923136
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
318
Assets/Mapbox SDK/Mapbox/Unity/Editor/MapManagerEditor.cs
Normal file
318
Assets/Mapbox SDK/Mapbox/Unity/Editor/MapManagerEditor.cs
Normal file
@@ -0,0 +1,318 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using Mapbox.Unity.Map;
|
||||
using Mapbox.Platform.TilesetTileJSON;
|
||||
using System.Collections.Generic;
|
||||
using Mapbox.VectorTile.ExtensionMethods;
|
||||
|
||||
[CustomEditor(typeof(AbstractMap))]
|
||||
[CanEditMultipleObjects]
|
||||
public class MapManagerEditor : Editor
|
||||
{
|
||||
|
||||
private string objectId = "";
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether to show general section <see cref="T:Mapbox.Editor.MapManagerEditor"/>.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> then show general section; otherwise hide, <c>false</c>.</value>
|
||||
bool ShowGeneral
|
||||
{
|
||||
get
|
||||
{
|
||||
return EditorPrefs.GetBool(objectId + "MapManagerEditor_showGeneral");
|
||||
}
|
||||
set
|
||||
{
|
||||
EditorPrefs.SetBool(objectId + "MapManagerEditor_showGeneral", value);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets a value to show or hide Image section<see cref="T:Mapbox.Editor.MapManagerEditor"/>.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if show image; otherwise, <c>false</c>.</value>
|
||||
bool ShowImage
|
||||
{
|
||||
get
|
||||
{
|
||||
return EditorPrefs.GetBool(objectId + "MapManagerEditor_showImage");
|
||||
}
|
||||
set
|
||||
{
|
||||
EditorPrefs.SetBool(objectId + "MapManagerEditor_showImage", value);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets a value to show or hide Terrain section <see cref="T:Mapbox.Editor.MapManagerEditor"/>
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if show terrain; otherwise, <c>false</c>.</value>
|
||||
bool ShowTerrain
|
||||
{
|
||||
get
|
||||
{
|
||||
return EditorPrefs.GetBool(objectId + "MapManagerEditor_showTerrain");
|
||||
}
|
||||
set
|
||||
{
|
||||
EditorPrefs.SetBool(objectId + "MapManagerEditor_showTerrain", value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value to show or hide Map Layers section <see cref="T:Mapbox.Editor.MapManagerEditor"/> show features.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if show features; otherwise, <c>false</c>.</value>
|
||||
bool ShowMapLayers
|
||||
{
|
||||
get
|
||||
{
|
||||
return EditorPrefs.GetBool(objectId + "MapManagerEditor_showMapLayers");
|
||||
}
|
||||
set
|
||||
{
|
||||
EditorPrefs.SetBool(objectId + "MapManagerEditor_showMapLayers", value);
|
||||
}
|
||||
}
|
||||
|
||||
bool ShowPosition
|
||||
{
|
||||
get
|
||||
{
|
||||
return EditorPrefs.GetBool(objectId + "MapManagerEditor_showPosition");
|
||||
}
|
||||
set
|
||||
{
|
||||
EditorPrefs.SetBool(objectId + "MapManagerEditor_showPosition", value);
|
||||
}
|
||||
}
|
||||
|
||||
private GUIContent mapIdGui = new GUIContent
|
||||
{
|
||||
text = "Map Id",
|
||||
tooltip = "Map Id corresponding to the tileset."
|
||||
};
|
||||
|
||||
bool _isGUIContentSet = false;
|
||||
GUIContent[] _sourceTypeContent;
|
||||
static float _lineHeight = EditorGUIUtility.singleLineHeight;
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
objectId = serializedObject.targetObject.GetInstanceID().ToString();
|
||||
serializedObject.Update();
|
||||
EditorGUILayout.BeginVertical();
|
||||
EditorGUILayout.Space();
|
||||
|
||||
ShowGeneral = EditorGUILayout.Foldout(ShowGeneral, new GUIContent { text = "GENERAL", tooltip = "Options related to map data" });
|
||||
|
||||
if (ShowGeneral)
|
||||
{
|
||||
DrawMapOptions(serializedObject);
|
||||
}
|
||||
ShowSepartor();
|
||||
|
||||
ShowImage = EditorGUILayout.Foldout(ShowImage, "IMAGE");
|
||||
if (ShowImage)
|
||||
{
|
||||
GUILayout.Space(-1.5f * _lineHeight);
|
||||
ShowSection(serializedObject.FindProperty("_imagery"), "_layerProperty");
|
||||
}
|
||||
|
||||
ShowSepartor();
|
||||
|
||||
ShowTerrain = EditorGUILayout.Foldout(ShowTerrain, "TERRAIN");
|
||||
if (ShowTerrain)
|
||||
{
|
||||
GUILayout.Space(-1.5f * _lineHeight);
|
||||
ShowSection(serializedObject.FindProperty("_terrain"), "_layerProperty");
|
||||
}
|
||||
|
||||
ShowSepartor();
|
||||
|
||||
ShowMapLayers = EditorGUILayout.Foldout(ShowMapLayers, "MAP LAYERS");
|
||||
if (ShowMapLayers)
|
||||
{
|
||||
DrawMapLayerOptions();
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
void ShowSection(SerializedProperty property, string propertyName)
|
||||
{
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.PropertyField(property.FindPropertyRelative(propertyName));
|
||||
}
|
||||
|
||||
void ShowSepartor()
|
||||
{
|
||||
EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
|
||||
void DrawMapOptions(SerializedObject mapObject)
|
||||
{
|
||||
var property = mapObject.FindProperty("_options");
|
||||
if (!((AbstractMap)serializedObject.targetObject).IsAccessTokenValid)
|
||||
{
|
||||
EditorGUILayout.HelpBox("Invalid Access Token. Please add a valid access token using the Mapbox > Setup Menu", MessageType.Error);
|
||||
}
|
||||
|
||||
EditorGUILayout.LabelField("Location ", GUILayout.Height(_lineHeight));
|
||||
|
||||
EditorGUILayout.PropertyField(property.FindPropertyRelative("locationOptions"));
|
||||
|
||||
|
||||
var extentOptions = property.FindPropertyRelative("extentOptions");
|
||||
var extentOptionsType = extentOptions.FindPropertyRelative("extentType");
|
||||
|
||||
|
||||
if ((MapExtentType)extentOptionsType.enumValueIndex == MapExtentType.Custom)
|
||||
{
|
||||
var tileProviderProperty = mapObject.FindProperty("_tileProvider");
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(extentOptionsType);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(extentOptions);
|
||||
}
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(tileProviderProperty);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
else
|
||||
{
|
||||
GUILayout.Space(-_lineHeight);
|
||||
EditorGUILayout.PropertyField(extentOptions);
|
||||
}
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("_initializeOnStart"));
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(property);
|
||||
}
|
||||
|
||||
ShowPosition = EditorGUILayout.Foldout(ShowPosition, "Others");
|
||||
if (ShowPosition)
|
||||
{
|
||||
GUILayout.Space(-_lineHeight);
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
var placementOptions = property.FindPropertyRelative("placementOptions");
|
||||
EditorGUILayout.PropertyField(placementOptions);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(placementOptions);
|
||||
}
|
||||
|
||||
GUILayout.Space(-_lineHeight);
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
var scalingOptions = property.FindPropertyRelative("scalingOptions");
|
||||
EditorGUILayout.PropertyField(scalingOptions);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(scalingOptions);
|
||||
}
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(property.FindPropertyRelative("loadingTexture"));
|
||||
EditorGUILayout.PropertyField(property.FindPropertyRelative("tileMaterial"));
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(property);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DrawMapLayerOptions()
|
||||
{
|
||||
var vectorDataProperty = serializedObject.FindProperty("_vectorData");
|
||||
var layerProperty = vectorDataProperty.FindPropertyRelative("_layerProperty");
|
||||
var layerSourceProperty = layerProperty.FindPropertyRelative("sourceOptions");
|
||||
var sourceTypeProperty = layerProperty.FindPropertyRelative("_sourceType");
|
||||
VectorSourceType sourceTypeValue = (VectorSourceType)sourceTypeProperty.enumValueIndex;
|
||||
var layerSourceId = layerProperty.FindPropertyRelative("sourceOptions.layerSource.Id");
|
||||
string layerString = layerSourceId.stringValue;
|
||||
var isActiveProperty = layerSourceProperty.FindPropertyRelative("isActive");
|
||||
|
||||
var displayNames = sourceTypeProperty.enumDisplayNames;
|
||||
int count = sourceTypeProperty.enumDisplayNames.Length;
|
||||
if (!_isGUIContentSet)
|
||||
{
|
||||
_sourceTypeContent = new GUIContent[count];
|
||||
for (int extIdx = 0; extIdx < count; extIdx++)
|
||||
{
|
||||
_sourceTypeContent[extIdx] = new GUIContent
|
||||
{
|
||||
text = displayNames[extIdx],
|
||||
tooltip = ((VectorSourceType)extIdx).Description(),
|
||||
};
|
||||
}
|
||||
|
||||
_isGUIContentSet = true;
|
||||
}
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
sourceTypeProperty.enumValueIndex = EditorGUILayout.Popup(new GUIContent
|
||||
{
|
||||
text = "Data Source",
|
||||
tooltip = "Source tileset for Vector Data"
|
||||
}, sourceTypeProperty.enumValueIndex, _sourceTypeContent);
|
||||
|
||||
sourceTypeValue = (VectorSourceType)sourceTypeProperty.enumValueIndex;
|
||||
|
||||
switch (sourceTypeValue)
|
||||
{
|
||||
case VectorSourceType.MapboxStreets:
|
||||
case VectorSourceType.MapboxStreetsWithBuildingIds:
|
||||
var sourcePropertyValue = MapboxDefaultVector.GetParameters(sourceTypeValue);
|
||||
layerSourceId.stringValue = sourcePropertyValue.Id;
|
||||
GUI.enabled = false;
|
||||
EditorGUILayout.PropertyField(layerSourceProperty, mapIdGui);
|
||||
GUI.enabled = true;
|
||||
isActiveProperty.boolValue = true;
|
||||
break;
|
||||
case VectorSourceType.Custom:
|
||||
EditorGUILayout.PropertyField(layerSourceProperty, mapIdGui);
|
||||
isActiveProperty.boolValue = true;
|
||||
break;
|
||||
case VectorSourceType.None:
|
||||
isActiveProperty.boolValue = false;
|
||||
break;
|
||||
default:
|
||||
isActiveProperty.boolValue = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(layerProperty);
|
||||
}
|
||||
|
||||
if (sourceTypeValue != VectorSourceType.None)
|
||||
{
|
||||
var isStyleOptimized = layerProperty.FindPropertyRelative("useOptimizedStyle");
|
||||
EditorGUILayout.PropertyField(isStyleOptimized);
|
||||
|
||||
if (isStyleOptimized.boolValue)
|
||||
{
|
||||
EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("optimizedStyle"), new GUIContent("Style Options"));
|
||||
}
|
||||
GUILayout.Space(-_lineHeight);
|
||||
EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("performanceOptions"), new GUIContent("Perfomance Options"));
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
ShowSepartor();
|
||||
|
||||
GUILayout.Space(-2.0f * _lineHeight);
|
||||
ShowSection(serializedObject.FindProperty("_vectorData"), "_layerProperty");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0fe5a867f0f1546009ebdda576486b9e
|
||||
timeCreated: 1518137782
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
68
Assets/Mapbox SDK/Mapbox/Unity/Editor/MapVisualizerEditor.cs
Normal file
68
Assets/Mapbox SDK/Mapbox/Unity/Editor/MapVisualizerEditor.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using Mapbox.Unity.MeshGeneration.Factories;
|
||||
using Mapbox.Editor.NodeEditor;
|
||||
using Mapbox.Unity.Map;
|
||||
|
||||
[CustomEditor(typeof(MapVisualizer))]
|
||||
public class MapVisualizerEditor : UnityEditor.Editor
|
||||
{
|
||||
private MonoScript script;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
script = MonoScript.FromScriptableObject((MapVisualizer)target);
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
GUI.enabled = false;
|
||||
script = EditorGUILayout.ObjectField("Script", script, typeof(MonoScript), false) as MonoScript;
|
||||
GUI.enabled = true;
|
||||
|
||||
var texture = serializedObject.FindProperty("_loadingTexture");
|
||||
EditorGUILayout.ObjectField(texture, typeof(Texture2D));
|
||||
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("Factories");
|
||||
var facs = serializedObject.FindProperty("Factories");
|
||||
for (int i = 0; i < facs.arraySize; i++)
|
||||
{
|
||||
var ind = i;
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.BeginVertical();
|
||||
GUILayout.Space(5);
|
||||
facs.GetArrayElementAtIndex(ind).objectReferenceValue = EditorGUILayout.ObjectField(facs.GetArrayElementAtIndex(i).objectReferenceValue, typeof(AbstractTileFactory), false) as ScriptableObject;
|
||||
EditorGUILayout.EndVertical();
|
||||
|
||||
if (GUILayout.Button(NodeBasedEditor.magnifierTexture, (GUIStyle)"minibuttonleft", GUILayout.Width(30)))
|
||||
{
|
||||
ScriptableCreatorWindow.Open(typeof(AbstractTileFactory), facs, ind);
|
||||
}
|
||||
if (GUILayout.Button(new GUIContent("-"), (GUIStyle)"minibuttonright", GUILayout.Width(30), GUILayout.Height(22)))
|
||||
{
|
||||
facs.DeleteArrayElementAtIndex(ind);
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
if (GUILayout.Button(new GUIContent("Add New Empty"), (GUIStyle)"minibuttonleft"))
|
||||
{
|
||||
facs.arraySize++;
|
||||
facs.GetArrayElementAtIndex(facs.arraySize - 1).objectReferenceValue = null;
|
||||
}
|
||||
if (GUILayout.Button(new GUIContent("Find Asset"), (GUIStyle)"minibuttonright"))
|
||||
{
|
||||
ScriptableCreatorWindow.Open(typeof(AbstractTileFactory), facs);
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user