[TASK] Initial commit with basic product setup
This commit is contained in:
@@ -0,0 +1,218 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using UnityEditor;
|
||||
using Mapbox.Unity.Map;
|
||||
using Mapbox.Unity.MeshGeneration.Modifiers;
|
||||
|
||||
public class BehaviorModifiersSectionDrawer
|
||||
{
|
||||
string objectId = "";
|
||||
|
||||
bool showGameplay
|
||||
{
|
||||
get
|
||||
{
|
||||
return EditorPrefs.GetBool(objectId + "VectorSubLayerProperties_showGameplay");
|
||||
}
|
||||
set
|
||||
{
|
||||
EditorPrefs.SetBool(objectId + "VectorSubLayerProperties_showGameplay", value);
|
||||
}
|
||||
}
|
||||
|
||||
public void DrawUI(SerializedProperty layerProperty, VectorPrimitiveType primitiveTypeProp, VectorSourceType sourceType)
|
||||
{
|
||||
|
||||
showGameplay = EditorGUILayout.Foldout(showGameplay, "Behavior Modifiers");
|
||||
if (showGameplay)
|
||||
{
|
||||
|
||||
bool isPrimitiveTypeValidForBuidingIds = (primitiveTypeProp == VectorPrimitiveType.Polygon || primitiveTypeProp == VectorPrimitiveType.Custom);
|
||||
bool isSourceValidForBuildingIds = sourceType != VectorSourceType.MapboxStreets;
|
||||
|
||||
layerProperty.FindPropertyRelative("honorBuildingIdSetting").boolValue = isPrimitiveTypeValidForBuidingIds && isSourceValidForBuildingIds;
|
||||
|
||||
if (layerProperty.FindPropertyRelative("honorBuildingIdSetting").boolValue == true)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("buildingsWithUniqueIds"), new GUIContent
|
||||
{
|
||||
text = "Buildings With Unique Ids",
|
||||
tooltip =
|
||||
"Turn on this setting only when rendering 3D buildings from the Mapbox Streets with Building Ids tileset. Using this setting with any other polygon layers or source will result in visual artifacts. "
|
||||
});
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(layerProperty);
|
||||
}
|
||||
}
|
||||
|
||||
var subLayerCoreOptions = layerProperty.FindPropertyRelative("coreOptions");
|
||||
var combineMeshesProperty = subLayerCoreOptions.FindPropertyRelative("combineMeshes");
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
if (combineMeshesProperty.boolValue == false)
|
||||
{
|
||||
var featurePositionProperty = layerProperty.FindPropertyRelative("moveFeaturePositionTo");
|
||||
GUIContent dropDownLabel = new GUIContent
|
||||
{
|
||||
text = "Feature Position",
|
||||
tooltip = "Position to place feature in the tile. "
|
||||
};
|
||||
|
||||
GUIContent[] dropDownItems = new GUIContent[featurePositionProperty.enumDisplayNames.Length];
|
||||
|
||||
for (int i = 0; i < featurePositionProperty.enumDisplayNames.Length; i++)
|
||||
{
|
||||
dropDownItems[i] = new GUIContent
|
||||
{
|
||||
text = featurePositionProperty.enumDisplayNames[i]
|
||||
};
|
||||
}
|
||||
EditorGUI.BeginChangeCheck();
|
||||
featurePositionProperty.enumValueIndex = EditorGUILayout.Popup(dropDownLabel, featurePositionProperty.enumValueIndex, dropDownItems);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(layerProperty);
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
DrawMeshModifiers(layerProperty);
|
||||
DrawGoModifiers(layerProperty);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawMeshModifiers(SerializedProperty property)
|
||||
{
|
||||
|
||||
EditorGUILayout.BeginVertical();
|
||||
EditorGUILayout.LabelField(new GUIContent
|
||||
{
|
||||
text = "Mesh Modifiers",
|
||||
tooltip = "Modifiers that manipulate the features mesh. "
|
||||
});
|
||||
|
||||
var meshfac = property.FindPropertyRelative("MeshModifiers");
|
||||
|
||||
for (int i = 0; i < meshfac.arraySize; i++)
|
||||
{
|
||||
var ind = i;
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
|
||||
EditorGUILayout.BeginVertical();
|
||||
meshfac.GetArrayElementAtIndex(ind).objectReferenceValue =
|
||||
EditorGUILayout.ObjectField(meshfac.GetArrayElementAtIndex(i).objectReferenceValue, typeof(MeshModifier), false)
|
||||
as ScriptableObject;
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
|
||||
if (GUILayout.Button(new GUIContent("x"), (GUIStyle)"minibuttonright", GUILayout.Width(30)))
|
||||
{
|
||||
bool elementWasDeleted = false;
|
||||
if (meshfac.arraySize > 0)
|
||||
{
|
||||
meshfac.DeleteArrayElementAtIndex(ind);
|
||||
elementWasDeleted = true;
|
||||
}
|
||||
if (meshfac.arraySize > 0)
|
||||
{
|
||||
meshfac.DeleteArrayElementAtIndex(ind);
|
||||
}
|
||||
if (elementWasDeleted)
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(property);
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
GUILayout.Space(EditorGUI.indentLevel * 12);
|
||||
Rect buttonRect = GUILayoutUtility.GetLastRect();
|
||||
if (GUILayout.Button(new GUIContent("Add New"), (GUIStyle)"minibuttonleft"))
|
||||
{
|
||||
PopupWindow.Show(buttonRect, new PopupSelectionMenu(typeof(MeshModifier), meshfac));
|
||||
if (Event.current.type == EventType.Repaint) buttonRect = GUILayoutUtility.GetLastRect();
|
||||
}
|
||||
|
||||
if (GUILayout.Button(new GUIContent("Add Existing"), (GUIStyle)"minibuttonright"))
|
||||
{
|
||||
ScriptableCreatorWindow.Open(typeof(MeshModifier), meshfac, -1, null, property);
|
||||
}
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUILayout.EndVertical();
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
private void DrawGoModifiers(SerializedProperty property)
|
||||
{
|
||||
|
||||
EditorGUILayout.BeginVertical();
|
||||
|
||||
EditorGUILayout.LabelField(new GUIContent
|
||||
{
|
||||
text = "Game Object Modifiers",
|
||||
tooltip = "Modifiers that manipulate the GameObject after mesh generation."
|
||||
});
|
||||
var gofac = property.FindPropertyRelative("GoModifiers");
|
||||
|
||||
for (int i = 0; i < gofac.arraySize; i++)
|
||||
{
|
||||
var ind = i;
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.BeginVertical();
|
||||
GUILayout.Space(5);
|
||||
gofac.GetArrayElementAtIndex(ind).objectReferenceValue =
|
||||
EditorGUILayout.ObjectField(gofac.GetArrayElementAtIndex(i).objectReferenceValue, typeof(GameObjectModifier),
|
||||
false) as ScriptableObject;
|
||||
EditorGUILayout.EndVertical();
|
||||
|
||||
if (GUILayout.Button(new GUIContent("x"), GUILayout.Width(30)))
|
||||
{
|
||||
bool elementWasDeleted = false;
|
||||
if (gofac.arraySize > 0)
|
||||
{
|
||||
gofac.DeleteArrayElementAtIndex(ind);
|
||||
elementWasDeleted = true;
|
||||
}
|
||||
if (gofac.arraySize > 0)
|
||||
{
|
||||
gofac.DeleteArrayElementAtIndex(ind);
|
||||
}
|
||||
if (elementWasDeleted)
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(property);
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
GUILayout.Space(EditorGUI.indentLevel * 12);
|
||||
Rect buttonRect = GUILayoutUtility.GetLastRect();
|
||||
|
||||
if (GUILayout.Button(new GUIContent("Add New"), (GUIStyle)"minibuttonleft"))
|
||||
{
|
||||
PopupWindow.Show(buttonRect, new PopupSelectionMenu(typeof(GameObjectModifier), gofac));
|
||||
if (Event.current.type == EventType.Repaint) buttonRect = GUILayoutUtility.GetLastRect();
|
||||
}
|
||||
|
||||
if (GUILayout.Button(new GUIContent("Add Existing"), (GUIStyle)"minibuttonright"))
|
||||
{
|
||||
|
||||
ScriptableCreatorWindow.Open(typeof(GameObjectModifier), gofac, -1, null, property);
|
||||
}
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUI.indentLevel--;
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4301f1990a1f8417280b87eb43510a4c
|
||||
timeCreated: 1533828994
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Mapbox.Unity.Map;
|
||||
|
||||
[CustomPropertyDrawer(typeof(CameraBoundsTileProviderOptions))]
|
||||
public class CameraBoundsTileProviderOptionsDrawer : PropertyDrawer
|
||||
{
|
||||
static float _lineHeight = EditorGUIUtility.singleLineHeight;
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
var camera = property.FindPropertyRelative("camera");
|
||||
EditorGUILayout.PropertyField(camera, new GUIContent
|
||||
{
|
||||
text = camera.displayName,
|
||||
tooltip = "Camera to control map extent."
|
||||
}, GUILayout.Height(_lineHeight));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: edfd5847c11274df4a63d74e142d6695
|
||||
timeCreated: 1517858264
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,58 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Mapbox.Unity.Map;
|
||||
using Mapbox.VectorTile.ExtensionMethods;
|
||||
using Mapbox.Editor;
|
||||
|
||||
[CustomPropertyDrawer(typeof(ColliderOptions))]
|
||||
public class ColliderOptionsDrawer : PropertyDrawer
|
||||
{
|
||||
static float lineHeight = EditorGUIUtility.singleLineHeight;
|
||||
bool isGUIContentSet = false;
|
||||
GUIContent[] colliderTypeContent;
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
EditorGUI.BeginProperty(position, null, property);
|
||||
var colliderTypeLabel = new GUIContent
|
||||
{
|
||||
text = "Collider Type",
|
||||
tooltip = "The type of collider added to game objects in this layer."
|
||||
};
|
||||
var colliderTypeProperty = property.FindPropertyRelative("colliderType");
|
||||
|
||||
var displayNames = colliderTypeProperty.enumDisplayNames;
|
||||
int count = colliderTypeProperty.enumDisplayNames.Length;
|
||||
|
||||
if (!isGUIContentSet)
|
||||
{
|
||||
colliderTypeContent = new GUIContent[count];
|
||||
for (int extIdx = 0; extIdx < count; extIdx++)
|
||||
{
|
||||
colliderTypeContent[extIdx] = new GUIContent
|
||||
{
|
||||
text = displayNames[extIdx],
|
||||
tooltip = EnumExtensions.Description((ColliderType)extIdx),
|
||||
};
|
||||
}
|
||||
isGUIContentSet = true;
|
||||
}
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
colliderTypeProperty.enumValueIndex = EditorGUILayout.Popup(colliderTypeLabel, colliderTypeProperty.enumValueIndex, colliderTypeContent);
|
||||
if(EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(property);
|
||||
}
|
||||
|
||||
EditorGUI.EndProperty();
|
||||
}
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
return lineHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 05ab73c42b3654a68823b6793c470531
|
||||
timeCreated: 1522459817
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,67 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Mapbox.Unity.Map;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System;
|
||||
using Mapbox.VectorTile.ExtensionMethods;
|
||||
using Mapbox.Editor;
|
||||
|
||||
[CustomPropertyDrawer(typeof(CoreVectorLayerProperties))]
|
||||
public class CoreVectorLayerPropertiesDrawer : PropertyDrawer
|
||||
{
|
||||
bool _isGUIContentSet = false;
|
||||
GUIContent[] _primitiveTypeContent;
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
|
||||
EditorGUI.BeginProperty(position, null, property);
|
||||
|
||||
var primitiveType = property.FindPropertyRelative("geometryType");
|
||||
|
||||
var primitiveTypeLabel = new GUIContent
|
||||
{
|
||||
text = "Primitive Type",
|
||||
tooltip = "Primitive geometry type of the visualizer, allowed primitives - point, line, polygon."
|
||||
};
|
||||
|
||||
var displayNames = primitiveType.enumDisplayNames;
|
||||
int count = primitiveType.enumDisplayNames.Length;
|
||||
|
||||
if (!_isGUIContentSet)
|
||||
{
|
||||
_primitiveTypeContent = new GUIContent[count];
|
||||
for (int extIdx = 0; extIdx < count; extIdx++)
|
||||
{
|
||||
_primitiveTypeContent[extIdx] = new GUIContent
|
||||
{
|
||||
text = displayNames[extIdx],
|
||||
tooltip = EnumExtensions.Description((VectorPrimitiveType)extIdx),
|
||||
};
|
||||
}
|
||||
_isGUIContentSet = true;
|
||||
}
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
primitiveType.enumValueIndex = EditorGUILayout.Popup(primitiveTypeLabel, primitiveType.enumValueIndex, _primitiveTypeContent);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(property);
|
||||
}
|
||||
//
|
||||
// if ((VectorPrimitiveType)primitiveType.enumValueIndex == VectorPrimitiveType.Line)
|
||||
// {
|
||||
// EditorGUI.BeginChangeCheck();
|
||||
// EditorGUILayout.PropertyField(property.FindPropertyRelative("lineWidth"));
|
||||
// if (EditorGUI.EndChangeCheck())
|
||||
// {
|
||||
// EditorHelper.CheckForModifiedProperty(property);
|
||||
// }
|
||||
// }
|
||||
EditorGUI.EndProperty();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a198cd5919ca149099130ba68e0f258b
|
||||
timeCreated: 1521052834
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,163 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Mapbox.Unity.Map;
|
||||
using Mapbox.VectorTile.ExtensionMethods;
|
||||
|
||||
[CustomPropertyDrawer(typeof(ElevationLayerProperties))]
|
||||
public class ElevationLayerPropertiesDrawer : PropertyDrawer
|
||||
{
|
||||
string objectId = "";
|
||||
static float lineHeight = EditorGUIUtility.singleLineHeight;
|
||||
GUIContent[] sourceTypeContent;
|
||||
bool isGUIContentSet = false;
|
||||
|
||||
bool ShowPosition
|
||||
{
|
||||
get
|
||||
{
|
||||
return EditorPrefs.GetBool(objectId + "ElevationLayerProperties_showPosition");
|
||||
}
|
||||
set
|
||||
{
|
||||
EditorPrefs.SetBool(objectId + "ElevationLayerProperties_showPosition", value);
|
||||
}
|
||||
}
|
||||
|
||||
private GUIContent _mapIdGui = new GUIContent
|
||||
{
|
||||
text = "Map Id",
|
||||
tooltip = "Map Id corresponding to the tileset."
|
||||
};
|
||||
|
||||
string CustomSourceMapId
|
||||
{
|
||||
get
|
||||
{
|
||||
return EditorPrefs.GetString(objectId + "ElevationLayerProperties_customSourceMapId");
|
||||
}
|
||||
set
|
||||
{
|
||||
EditorPrefs.SetString(objectId + "ElevationLayerProperties_customSourceMapId", value);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
objectId = property.serializedObject.targetObject.GetInstanceID().ToString();
|
||||
|
||||
var sourceTypeProperty = property.FindPropertyRelative("sourceType");
|
||||
|
||||
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 = ((ElevationSourceType)extIdx).Description(),
|
||||
};
|
||||
}
|
||||
isGUIContentSet = true;
|
||||
}
|
||||
var sourceTypeLabel = new GUIContent { text = "Data Source", tooltip = "Source tileset for Terrain." };
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
sourceTypeProperty.enumValueIndex = EditorGUILayout.Popup(sourceTypeLabel, sourceTypeProperty.enumValueIndex, sourceTypeContent);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(property);
|
||||
}
|
||||
|
||||
var sourceTypeValue = (ElevationSourceType)sourceTypeProperty.enumValueIndex;
|
||||
|
||||
var sourceOptionsProperty = property.FindPropertyRelative("sourceOptions");
|
||||
var layerSourceProperty = sourceOptionsProperty.FindPropertyRelative("layerSource");
|
||||
var layerSourceId = layerSourceProperty.FindPropertyRelative("Id");
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
switch (sourceTypeValue)
|
||||
{
|
||||
case ElevationSourceType.MapboxTerrain:
|
||||
var sourcePropertyValue = MapboxDefaultElevation.GetParameters(sourceTypeValue);
|
||||
layerSourceId.stringValue = sourcePropertyValue.Id;
|
||||
GUI.enabled = false;
|
||||
EditorGUILayout.PropertyField(sourceOptionsProperty, _mapIdGui);
|
||||
GUI.enabled = true;
|
||||
break;
|
||||
case ElevationSourceType.Custom:
|
||||
layerSourceId.stringValue = string.IsNullOrEmpty(CustomSourceMapId) ? MapboxDefaultElevation.GetParameters(ElevationSourceType.MapboxTerrain).Id : CustomSourceMapId;
|
||||
EditorGUILayout.PropertyField(sourceOptionsProperty, _mapIdGui);
|
||||
CustomSourceMapId = layerSourceId.stringValue;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(property);
|
||||
}
|
||||
|
||||
var elevationLayerType = property.FindPropertyRelative("elevationLayerType");
|
||||
|
||||
if (sourceTypeValue == ElevationSourceType.None)
|
||||
{
|
||||
GUI.enabled = false;
|
||||
elevationLayerType.enumValueIndex = (int)ElevationLayerType.FlatTerrain;
|
||||
}
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(property.FindPropertyRelative("elevationLayerType"), new GUIContent { text = elevationLayerType.displayName, tooltip = ((ElevationLayerType)elevationLayerType.enumValueIndex).Description() });
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(property);
|
||||
}
|
||||
|
||||
if (sourceTypeValue == ElevationSourceType.None)
|
||||
{
|
||||
GUI.enabled = true;
|
||||
}
|
||||
|
||||
GUILayout.Space(-lineHeight);
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(property.FindPropertyRelative("colliderOptions"), true);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(property.FindPropertyRelative("colliderOptions"));
|
||||
}
|
||||
GUILayout.Space(2 * -lineHeight);
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(property.FindPropertyRelative("requiredOptions"), true);
|
||||
GUILayout.Space(-lineHeight);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(property);
|
||||
}
|
||||
|
||||
ShowPosition = EditorGUILayout.Foldout(ShowPosition, "Others");
|
||||
|
||||
if (ShowPosition)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
EditorGUILayout.PropertyField(property.FindPropertyRelative("modificationOptions"), true);
|
||||
|
||||
EditorGUILayout.PropertyField(property.FindPropertyRelative("sideWallOptions"), true);
|
||||
|
||||
EditorGUILayout.PropertyField(property.FindPropertyRelative("unityLayerOptions"), true);
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(property);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: becc811ca916a4717bf81685180e605d
|
||||
timeCreated: 1520010402
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,28 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Mapbox.Unity.Map;
|
||||
|
||||
[CustomPropertyDrawer(typeof(ElevationModificationOptions))]
|
||||
public class ElevationModificationOptionsDrawer : PropertyDrawer
|
||||
{
|
||||
static float lineHeight = EditorGUIUtility.singleLineHeight;
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
EditorGUI.BeginProperty(position, label, property);
|
||||
EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("sampleCount"));
|
||||
position.y += lineHeight;
|
||||
EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("useRelativeHeight"));
|
||||
position.y += lineHeight;
|
||||
EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("earthRadius"));
|
||||
EditorGUI.EndProperty();
|
||||
}
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
// Reserve space for the total visible properties.
|
||||
return 3.0f * lineHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 299ec1d2adf5f4418aa69f1441d59731
|
||||
timeCreated: 1521052834
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,27 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Mapbox.Unity.Map;
|
||||
|
||||
[CustomPropertyDrawer(typeof(ElevationRequiredOptions))]
|
||||
public class ElevationRequiredOptionsDrawer : PropertyDrawer
|
||||
{
|
||||
static float lineHeight = EditorGUIUtility.singleLineHeight;
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
EditorGUI.BeginProperty(position, label, property);
|
||||
|
||||
position.y += lineHeight;
|
||||
EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("exaggerationFactor"));
|
||||
|
||||
EditorGUI.EndProperty();
|
||||
}
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
// Reserve space for the total visible properties.
|
||||
return 3.0f * lineHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0b69c5574214341c9888bda16d659aee
|
||||
timeCreated: 1521052834
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,26 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Mapbox.Unity.MeshGeneration.Modifiers;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
/*
|
||||
[CustomPropertyDrawer(typeof(FeatureBundleList))]
|
||||
public class FeatureBundleListDrawer : PropertyDrawer
|
||||
{
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
var features = property.FindPropertyRelative("features");
|
||||
for (int i = 0; i < features.arraySize; i++)
|
||||
{
|
||||
var feature = features.GetArrayElementAtIndex(i);
|
||||
var name = feature.FindPropertyRelative("features");
|
||||
//EditorGUILayout.PropertyField(extrusionGeometryType, extrusionGeometryGUI);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fc7416265a7cf4abda73c7224be18d0a
|
||||
timeCreated: 1533675584
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,711 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using Mapbox.Unity.Map;
|
||||
using UnityEditor.IMGUI.Controls;
|
||||
using Mapbox.Unity.MeshGeneration.Modifiers;
|
||||
using Mapbox.VectorTile.ExtensionMethods;
|
||||
using Mapbox.Unity.MeshGeneration.Filters;
|
||||
using Mapbox.Platform.TilesetTileJSON;
|
||||
using Mapbox.Editor;
|
||||
using System;
|
||||
|
||||
public class FeaturesSubLayerPropertiesDrawer
|
||||
{
|
||||
static float _lineHeight = EditorGUIUtility.singleLineHeight;
|
||||
GUIContent[] _sourceTypeContent;
|
||||
bool _isGUIContentSet = false;
|
||||
bool _isInitialized = false;
|
||||
private TileJsonData tileJSONData;
|
||||
private static TileJSONResponse tileJSONResponse;
|
||||
static TileJsonData tileJsonData = new TileJsonData();
|
||||
int _layerIndex = 0;
|
||||
GUIContent[] _layerTypeContent;
|
||||
private static VectorSubLayerProperties subLayerProperties;
|
||||
private TreeModel<FeatureTreeElement> treeModel;
|
||||
|
||||
private static string[] names;
|
||||
[SerializeField]
|
||||
TreeViewState m_TreeViewState;
|
||||
|
||||
[SerializeField]
|
||||
MultiColumnHeaderState m_MultiColumnHeaderState;
|
||||
|
||||
bool m_Initialized = false;
|
||||
string objectId = "";
|
||||
private string TilesetId
|
||||
{
|
||||
get
|
||||
{
|
||||
return EditorPrefs.GetString(objectId + "VectorSubLayerProperties_tilesetId");
|
||||
}
|
||||
set
|
||||
{
|
||||
EditorPrefs.SetString(objectId + "VectorSubLayerProperties_tilesetId", value);
|
||||
}
|
||||
}
|
||||
|
||||
bool ShowPosition
|
||||
{
|
||||
get
|
||||
{
|
||||
return EditorPrefs.GetBool(objectId + "VectorSubLayerProperties_showPosition");
|
||||
}
|
||||
set
|
||||
{
|
||||
EditorPrefs.SetBool(objectId + "VectorSubLayerProperties_showPosition", value);
|
||||
}
|
||||
}
|
||||
|
||||
int SelectionIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return EditorPrefs.GetInt(objectId + "VectorSubLayerProperties_selectionIndex");
|
||||
}
|
||||
set
|
||||
{
|
||||
EditorPrefs.SetInt(objectId + "VectorSubLayerProperties_selectionIndex", value);
|
||||
}
|
||||
}
|
||||
|
||||
ModelingSectionDrawer _modelingSectionDrawer = new ModelingSectionDrawer();
|
||||
BehaviorModifiersSectionDrawer _behaviorModifierSectionDrawer = new BehaviorModifiersSectionDrawer();
|
||||
|
||||
private static TileStats _streetsV7TileStats;
|
||||
private static string[] subTypeValues;
|
||||
FeatureSubLayerTreeView layerTreeView;
|
||||
IList<int> selectedLayers = new List<int>();
|
||||
public void DrawUI(SerializedProperty property)
|
||||
{
|
||||
|
||||
objectId = property.serializedObject.targetObject.GetInstanceID().ToString();
|
||||
var serializedMapObject = property.serializedObject;
|
||||
AbstractMap mapObject = (AbstractMap)serializedMapObject.targetObject;
|
||||
tileJSONData = mapObject.VectorData.GetTileJsonData();
|
||||
|
||||
var sourceTypeProperty = property.FindPropertyRelative("_sourceType");
|
||||
var sourceTypeValue = (VectorSourceType)sourceTypeProperty.enumValueIndex;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
sourceTypeValue = (VectorSourceType)sourceTypeProperty.enumValueIndex;
|
||||
|
||||
var sourceOptionsProperty = property.FindPropertyRelative("sourceOptions");
|
||||
var layerSourceProperty = sourceOptionsProperty.FindPropertyRelative("layerSource");
|
||||
var layerSourceId = layerSourceProperty.FindPropertyRelative("Id");
|
||||
var isActiveProperty = sourceOptionsProperty.FindPropertyRelative("isActive");
|
||||
switch (sourceTypeValue)
|
||||
{
|
||||
case VectorSourceType.MapboxStreets:
|
||||
case VectorSourceType.MapboxStreetsWithBuildingIds:
|
||||
var sourcePropertyValue = MapboxDefaultVector.GetParameters(sourceTypeValue);
|
||||
layerSourceId.stringValue = sourcePropertyValue.Id;
|
||||
GUI.enabled = false;
|
||||
if (_isInitialized)
|
||||
{
|
||||
LoadEditorTileJSON(property, sourceTypeValue, layerSourceId.stringValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
_isInitialized = true;
|
||||
}
|
||||
if (tileJSONData.PropertyDisplayNames.Count == 0 && tileJSONData.tileJSONLoaded)
|
||||
{
|
||||
EditorGUILayout.HelpBox("Invalid Map Id / There might be a problem with the internet connection.", MessageType.Error);
|
||||
}
|
||||
GUI.enabled = true;
|
||||
isActiveProperty.boolValue = true;
|
||||
break;
|
||||
case VectorSourceType.Custom:
|
||||
if (_isInitialized)
|
||||
{
|
||||
string test = layerSourceId.stringValue;
|
||||
LoadEditorTileJSON(property, sourceTypeValue, layerSourceId.stringValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
_isInitialized = true;
|
||||
}
|
||||
if (tileJSONData.PropertyDisplayNames.Count == 0 && tileJSONData.tileJSONLoaded)
|
||||
{
|
||||
EditorGUILayout.HelpBox("Invalid Map Id / There might be a problem with the internet connection.", MessageType.Error);
|
||||
}
|
||||
isActiveProperty.boolValue = true;
|
||||
break;
|
||||
case VectorSourceType.None:
|
||||
isActiveProperty.boolValue = false;
|
||||
break;
|
||||
default:
|
||||
isActiveProperty.boolValue = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (sourceTypeValue != VectorSourceType.None)
|
||||
{
|
||||
EditorGUILayout.LabelField(new GUIContent
|
||||
{
|
||||
text = "Map Features",
|
||||
tooltip = "Visualizers for vector features contained in a layer. "
|
||||
});
|
||||
|
||||
var subLayerArray = property.FindPropertyRelative("vectorSubLayers");
|
||||
|
||||
var layersRect = EditorGUILayout.GetControlRect(GUILayout.MinHeight(Mathf.Max(subLayerArray.arraySize + 1, 1) * _lineHeight + MultiColumnHeader.DefaultGUI.defaultHeight),
|
||||
GUILayout.MaxHeight((subLayerArray.arraySize + 1) * _lineHeight + MultiColumnHeader.DefaultGUI.defaultHeight));
|
||||
|
||||
if (!m_Initialized)
|
||||
{
|
||||
bool firstInit = m_MultiColumnHeaderState == null;
|
||||
var headerState = FeatureSubLayerTreeView.CreateDefaultMultiColumnHeaderState();
|
||||
if (MultiColumnHeaderState.CanOverwriteSerializedFields(m_MultiColumnHeaderState, headerState))
|
||||
{
|
||||
MultiColumnHeaderState.OverwriteSerializedFields(m_MultiColumnHeaderState, headerState);
|
||||
}
|
||||
m_MultiColumnHeaderState = headerState;
|
||||
|
||||
var multiColumnHeader = new FeatureSectionMultiColumnHeader(headerState);
|
||||
|
||||
if (firstInit)
|
||||
{
|
||||
multiColumnHeader.ResizeToFit();
|
||||
}
|
||||
|
||||
treeModel = new TreeModel<FeatureTreeElement>(GetData(subLayerArray));
|
||||
if (m_TreeViewState == null)
|
||||
{
|
||||
m_TreeViewState = new TreeViewState();
|
||||
}
|
||||
|
||||
if (layerTreeView == null)
|
||||
{
|
||||
layerTreeView = new FeatureSubLayerTreeView(m_TreeViewState, multiColumnHeader, treeModel);
|
||||
}
|
||||
layerTreeView.multiColumnHeader = multiColumnHeader;
|
||||
m_Initialized = true;
|
||||
}
|
||||
layerTreeView.Layers = subLayerArray;
|
||||
layerTreeView.Reload();
|
||||
layerTreeView.OnGUI(layersRect);
|
||||
|
||||
if (layerTreeView.hasChanged)
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(property);
|
||||
layerTreeView.hasChanged = false;
|
||||
}
|
||||
|
||||
selectedLayers = layerTreeView.GetSelection();
|
||||
|
||||
//if there are selected elements, set the selection index at the first element.
|
||||
//if not, use the Selection index to persist the selection at the right index.
|
||||
if (selectedLayers.Count > 0)
|
||||
{
|
||||
//ensure that selectedLayers[0] isn't out of bounds
|
||||
if (selectedLayers[0] - FeatureSubLayerTreeView.uniqueIdFeature > subLayerArray.arraySize - 1)
|
||||
{
|
||||
selectedLayers[0] = subLayerArray.arraySize - 1 + FeatureSubLayerTreeView.uniqueIdFeature;
|
||||
}
|
||||
|
||||
SelectionIndex = selectedLayers[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SelectionIndex > 0 && (SelectionIndex - FeatureSubLayerTreeView.uniqueIdFeature <= subLayerArray.arraySize - 1))
|
||||
{
|
||||
selectedLayers = new int[1] { SelectionIndex };
|
||||
layerTreeView.SetSelection(selectedLayers);
|
||||
}
|
||||
}
|
||||
|
||||
GUILayout.Space(EditorGUIUtility.singleLineHeight);
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
//var presetTypes = property.FindPropertyRelative("presetFeatureTypes");
|
||||
GenericMenu menu = new GenericMenu();
|
||||
foreach (var name in Enum.GetNames(typeof(PresetFeatureType)))
|
||||
{
|
||||
menu.AddItem(new GUIContent() { text = name }, false, FetchPresetProperties, name);
|
||||
}
|
||||
GUILayout.Space(0); // do not remove this line; it is needed for the next line to work
|
||||
Rect rect = GUILayoutUtility.GetLastRect();
|
||||
rect.y += 2 * _lineHeight / 3;
|
||||
|
||||
if (EditorGUILayout.DropdownButton(new GUIContent { text = "Add Feature" }, FocusType.Passive, (GUIStyle)"minibuttonleft"))
|
||||
{
|
||||
menu.DropDown(rect);
|
||||
}
|
||||
|
||||
//Assign subLayerProperties after fetching it from the presets class. This happens everytime an element is added
|
||||
if (subLayerProperties != null)
|
||||
{
|
||||
subLayerArray.arraySize++;
|
||||
var subLayer = subLayerArray.GetArrayElementAtIndex(subLayerArray.arraySize - 1);
|
||||
SetSubLayerProps(subLayer);
|
||||
|
||||
//Refreshing the tree
|
||||
layerTreeView.Layers = subLayerArray;
|
||||
layerTreeView.AddElementToTree(subLayer);
|
||||
layerTreeView.Reload();
|
||||
|
||||
selectedLayers = new int[1] { subLayerArray.arraySize - 1 + FeatureSubLayerTreeView.uniqueIdFeature };
|
||||
layerTreeView.SetSelection(selectedLayers);
|
||||
subLayerProperties = null; // setting this to null so that the if block is not called again
|
||||
|
||||
if (EditorHelper.DidModifyProperty(property))
|
||||
{
|
||||
((VectorLayerProperties)EditorHelper.GetTargetObjectOfProperty(property)).OnSubLayerPropertyAdded(new VectorLayerUpdateArgs { property = EditorHelper.GetTargetObjectOfProperty(subLayer) as MapboxDataProperty });
|
||||
}
|
||||
}
|
||||
|
||||
if (GUILayout.Button(new GUIContent("Remove Selected"), (GUIStyle)"minibuttonright"))
|
||||
{
|
||||
foreach (var index in selectedLayers.OrderByDescending(i => i))
|
||||
{
|
||||
if (layerTreeView != null)
|
||||
{
|
||||
var subLayer = subLayerArray.GetArrayElementAtIndex(index - FeatureSubLayerTreeView.uniqueIdFeature);
|
||||
|
||||
VectorLayerProperties vectorLayerProperties = (VectorLayerProperties)EditorHelper.GetTargetObjectOfProperty(property);
|
||||
VectorSubLayerProperties vectorSubLayerProperties = (VectorSubLayerProperties)EditorHelper.GetTargetObjectOfProperty(subLayer);
|
||||
|
||||
vectorLayerProperties.OnSubLayerPropertyRemoved(new VectorLayerUpdateArgs { property = vectorSubLayerProperties });
|
||||
|
||||
layerTreeView.RemoveItemFromTree(index);
|
||||
subLayerArray.DeleteArrayElementAtIndex(index - FeatureSubLayerTreeView.uniqueIdFeature);
|
||||
layerTreeView.treeModel.SetData(GetData(subLayerArray));
|
||||
}
|
||||
}
|
||||
|
||||
selectedLayers = new int[0];
|
||||
layerTreeView.SetSelection(selectedLayers);
|
||||
}
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
GUILayout.Space(EditorGUIUtility.singleLineHeight);
|
||||
|
||||
if (selectedLayers.Count == 1 && subLayerArray.arraySize != 0 && selectedLayers[0] - FeatureSubLayerTreeView.uniqueIdFeature >= 0)
|
||||
{
|
||||
//ensure that selectedLayers[0] isn't out of bounds
|
||||
if (selectedLayers[0] - FeatureSubLayerTreeView.uniqueIdFeature > subLayerArray.arraySize - 1)
|
||||
{
|
||||
selectedLayers[0] = subLayerArray.arraySize - 1 + FeatureSubLayerTreeView.uniqueIdFeature;
|
||||
}
|
||||
|
||||
SelectionIndex = selectedLayers[0];
|
||||
|
||||
var layerProperty = subLayerArray.GetArrayElementAtIndex(SelectionIndex - FeatureSubLayerTreeView.uniqueIdFeature);
|
||||
|
||||
layerProperty.isExpanded = true;
|
||||
var subLayerCoreOptions = layerProperty.FindPropertyRelative("coreOptions");
|
||||
bool isLayerActive = subLayerCoreOptions.FindPropertyRelative("isActive").boolValue;
|
||||
if (!isLayerActive)
|
||||
{
|
||||
GUI.enabled = false;
|
||||
}
|
||||
|
||||
DrawLayerVisualizerProperties(sourceTypeValue, layerProperty, property);
|
||||
|
||||
if (!isLayerActive)
|
||||
{
|
||||
GUI.enabled = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GUILayout.Label("Select a visualizer to see properties");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IList<FeatureTreeElement> GetData(SerializedProperty subLayerArray)
|
||||
{
|
||||
List<FeatureTreeElement> elements = new List<FeatureTreeElement>();
|
||||
string name = string.Empty;
|
||||
string type = string.Empty;
|
||||
int id = 0;
|
||||
var root = new FeatureTreeElement("Root", -1, 0);
|
||||
elements.Add(root);
|
||||
for (int i = 0; i < subLayerArray.arraySize; i++)
|
||||
{
|
||||
var subLayer = subLayerArray.GetArrayElementAtIndex(i);
|
||||
name = subLayer.FindPropertyRelative("coreOptions.sublayerName").stringValue;
|
||||
id = i + FeatureSubLayerTreeView.uniqueIdFeature;
|
||||
type = ((PresetFeatureType)subLayer.FindPropertyRelative("presetFeatureType").enumValueIndex).ToString();
|
||||
FeatureTreeElement element = new FeatureTreeElement(name, 0, id);
|
||||
element.Name = name;
|
||||
element.name = name;
|
||||
element.Type = type;
|
||||
elements.Add(element);
|
||||
}
|
||||
return elements;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fetches the preset properties using the supplied <see cref="PresetFeatureType">PresetFeatureType</see>
|
||||
/// </summary>
|
||||
/// <param name="name">Name.</param>
|
||||
void FetchPresetProperties(object name)
|
||||
{
|
||||
PresetFeatureType featureType = ((PresetFeatureType)Enum.Parse(typeof(PresetFeatureType), name.ToString()));
|
||||
subLayerProperties = PresetSubLayerPropertiesFetcher.GetSubLayerProperties(featureType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the sub layer properties for the newly added layer
|
||||
/// </summary>
|
||||
/// <param name="subLayer">Sub layer.</param>
|
||||
void SetSubLayerProps(SerializedProperty subLayer)
|
||||
{
|
||||
subLayer.FindPropertyRelative("coreOptions.sublayerName").stringValue = subLayerProperties.coreOptions.sublayerName;
|
||||
subLayer.FindPropertyRelative("presetFeatureType").enumValueIndex = (int)subLayerProperties.presetFeatureType;
|
||||
// Set defaults here because SerializedProperty copies the previous element.
|
||||
var subLayerCoreOptions = subLayer.FindPropertyRelative("coreOptions");
|
||||
CoreVectorLayerProperties coreOptions = subLayerProperties.coreOptions;
|
||||
subLayerCoreOptions.FindPropertyRelative("isActive").boolValue = coreOptions.isActive;
|
||||
subLayerCoreOptions.FindPropertyRelative("layerName").stringValue = coreOptions.layerName;
|
||||
subLayerCoreOptions.FindPropertyRelative("geometryType").enumValueIndex = (int)coreOptions.geometryType;
|
||||
subLayerCoreOptions.FindPropertyRelative("snapToTerrain").boolValue = coreOptions.snapToTerrain;
|
||||
subLayerCoreOptions.FindPropertyRelative("combineMeshes").boolValue = coreOptions.combineMeshes;
|
||||
|
||||
var subLayerlineGeometryOptions = subLayer.FindPropertyRelative("lineGeometryOptions");
|
||||
var lineGeometryOptions = subLayerProperties.lineGeometryOptions;
|
||||
subLayerlineGeometryOptions.FindPropertyRelative("Width").floatValue = lineGeometryOptions.Width;
|
||||
|
||||
var subLayerExtrusionOptions = subLayer.FindPropertyRelative("extrusionOptions");
|
||||
var extrusionOptions = subLayerProperties.extrusionOptions;
|
||||
subLayerExtrusionOptions.FindPropertyRelative("extrusionType").enumValueIndex = (int)extrusionOptions.extrusionType;
|
||||
subLayerExtrusionOptions.FindPropertyRelative("extrusionGeometryType").enumValueIndex = (int)extrusionOptions.extrusionGeometryType;
|
||||
subLayerExtrusionOptions.FindPropertyRelative("propertyName").stringValue = extrusionOptions.propertyName;
|
||||
subLayerExtrusionOptions.FindPropertyRelative("extrusionScaleFactor").floatValue = extrusionOptions.extrusionScaleFactor;
|
||||
subLayerExtrusionOptions.FindPropertyRelative("maximumHeight").floatValue = extrusionOptions.maximumHeight;
|
||||
|
||||
var subLayerFilterOptions = subLayer.FindPropertyRelative("filterOptions");
|
||||
var filterOptions = subLayerProperties.filterOptions;
|
||||
subLayerFilterOptions.FindPropertyRelative("filters").ClearArray();
|
||||
subLayerFilterOptions.FindPropertyRelative("combinerType").enumValueIndex = (int)filterOptions.combinerType;
|
||||
//Add any future filter related assignments here
|
||||
|
||||
var subLayerGeometryMaterialOptions = subLayer.FindPropertyRelative("materialOptions");
|
||||
var materialOptions = subLayerProperties.materialOptions;
|
||||
subLayerGeometryMaterialOptions.FindPropertyRelative("style").enumValueIndex = (int)materialOptions.style;
|
||||
|
||||
//GeometryMaterialOptions geometryMaterialOptionsReference = MapboxDefaultStyles.GetDefaultAssets();
|
||||
|
||||
var mats = subLayerGeometryMaterialOptions.FindPropertyRelative("materials");
|
||||
mats.arraySize = 2;
|
||||
|
||||
var topMatArray = mats.GetArrayElementAtIndex(0).FindPropertyRelative("Materials");
|
||||
var sideMatArray = mats.GetArrayElementAtIndex(1).FindPropertyRelative("Materials");
|
||||
|
||||
if (topMatArray.arraySize == 0)
|
||||
{
|
||||
topMatArray.arraySize = 1;
|
||||
}
|
||||
if (sideMatArray.arraySize == 0)
|
||||
{
|
||||
sideMatArray.arraySize = 1;
|
||||
}
|
||||
|
||||
var topMat = topMatArray.GetArrayElementAtIndex(0);
|
||||
var sideMat = sideMatArray.GetArrayElementAtIndex(0);
|
||||
|
||||
var atlas = subLayerGeometryMaterialOptions.FindPropertyRelative("atlasInfo");
|
||||
var palette = subLayerGeometryMaterialOptions.FindPropertyRelative("colorPalette");
|
||||
var lightStyleOpacity = subLayerGeometryMaterialOptions.FindPropertyRelative("lightStyleOpacity");
|
||||
var darkStyleOpacity = subLayerGeometryMaterialOptions.FindPropertyRelative("darkStyleOpacity");
|
||||
var customStyleOptions = subLayerGeometryMaterialOptions.FindPropertyRelative("customStyleOptions");
|
||||
|
||||
topMat.objectReferenceValue = materialOptions.materials[0].Materials[0];
|
||||
sideMat.objectReferenceValue = materialOptions.materials[1].Materials[0];
|
||||
atlas.objectReferenceValue = materialOptions.atlasInfo;
|
||||
palette.objectReferenceValue = materialOptions.colorPalette;
|
||||
lightStyleOpacity.floatValue = materialOptions.lightStyleOpacity;
|
||||
darkStyleOpacity.floatValue = materialOptions.darkStyleOpacity;
|
||||
|
||||
|
||||
//set custom style options.
|
||||
var customMats = customStyleOptions.FindPropertyRelative("materials");
|
||||
customMats.arraySize = 2;
|
||||
|
||||
var customTopMatArray = customMats.GetArrayElementAtIndex(0).FindPropertyRelative("Materials");
|
||||
var customSideMatArray = customMats.GetArrayElementAtIndex(1).FindPropertyRelative("Materials");
|
||||
|
||||
if (customTopMatArray.arraySize == 0)
|
||||
{
|
||||
customTopMatArray.arraySize = 1;
|
||||
}
|
||||
if (customSideMatArray.arraySize == 0)
|
||||
{
|
||||
customSideMatArray.arraySize = 1;
|
||||
}
|
||||
|
||||
var customTopMat = customTopMatArray.GetArrayElementAtIndex(0);
|
||||
var customSideMat = customSideMatArray.GetArrayElementAtIndex(0);
|
||||
|
||||
|
||||
customTopMat.objectReferenceValue = materialOptions.customStyleOptions.materials[0].Materials[0];
|
||||
customSideMat.objectReferenceValue = materialOptions.customStyleOptions.materials[1].Materials[0];
|
||||
customStyleOptions.FindPropertyRelative("atlasInfo").objectReferenceValue = materialOptions.customStyleOptions.atlasInfo;
|
||||
customStyleOptions.FindPropertyRelative("colorPalette").objectReferenceValue = materialOptions.customStyleOptions.colorPalette;
|
||||
|
||||
subLayer.FindPropertyRelative("buildingsWithUniqueIds").boolValue = subLayerProperties.buildingsWithUniqueIds;
|
||||
subLayer.FindPropertyRelative("moveFeaturePositionTo").enumValueIndex = (int)subLayerProperties.moveFeaturePositionTo;
|
||||
subLayer.FindPropertyRelative("MeshModifiers").ClearArray();
|
||||
subLayer.FindPropertyRelative("GoModifiers").ClearArray();
|
||||
|
||||
var subLayerColliderOptions = subLayer.FindPropertyRelative("colliderOptions");
|
||||
subLayerColliderOptions.FindPropertyRelative("colliderType").enumValueIndex = (int)subLayerProperties.colliderOptions.colliderType;
|
||||
}
|
||||
|
||||
private void UpdateMe()
|
||||
{
|
||||
Debug.Log("Update!");
|
||||
}
|
||||
|
||||
void DrawLayerVisualizerProperties(VectorSourceType sourceType, SerializedProperty layerProperty, SerializedProperty property)
|
||||
{
|
||||
var subLayerCoreOptions = layerProperty.FindPropertyRelative("coreOptions");
|
||||
//var layerName = layerProperty.FindPropertyRelative("coreOptions.layerName");
|
||||
//var roadLayerName = layerProperty.FindPropertyRelative("roadLayer");
|
||||
//var landuseLayerName = layerProperty.FindPropertyRelative("landuseLayer");
|
||||
|
||||
|
||||
var subLayerName = subLayerCoreOptions.FindPropertyRelative("sublayerName").stringValue;
|
||||
var visualizerLayer = subLayerCoreOptions.FindPropertyRelative("layerName").stringValue;
|
||||
var subLayerType = PresetSubLayerPropertiesFetcher.GetPresetTypeFromLayerName(visualizerLayer);
|
||||
//var maskValue = layerProperty.FindPropertyRelative("_maskValue");
|
||||
//var selectedTypes = layerProperty.FindPropertyRelative("selectedTypes");
|
||||
|
||||
GUILayout.Space(-_lineHeight);
|
||||
layerProperty.FindPropertyRelative("presetFeatureType").intValue = (int)subLayerType;
|
||||
//EditorGUILayout.LabelField("Sub-type : " + "Highway", visualizerNameAndType);
|
||||
GUILayout.Space(_lineHeight);
|
||||
//*********************** LAYER NAME BEGINS ***********************************//
|
||||
VectorPrimitiveType primitiveTypeProp = (VectorPrimitiveType)subLayerCoreOptions.FindPropertyRelative("geometryType").enumValueIndex;
|
||||
|
||||
var serializedMapObject = property.serializedObject;
|
||||
AbstractMap mapObject = (AbstractMap)serializedMapObject.targetObject;
|
||||
tileJsonData = mapObject.VectorData.GetTileJsonData();
|
||||
|
||||
var layerDisplayNames = tileJsonData.LayerDisplayNames;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
DrawLayerName(subLayerCoreOptions, layerDisplayNames);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(subLayerCoreOptions);
|
||||
}
|
||||
//*********************** LAYER NAME ENDS ***********************************//
|
||||
|
||||
//*********************** TYPE DROPDOWN BEGINS ***********************************//
|
||||
//if (_streetsV7TileStats == null || subTypeValues == null)
|
||||
//{
|
||||
// subTypeValues = GetSubTypeValues(layerProperty, visualizerLayer, sourceType);
|
||||
//}
|
||||
|
||||
//if ((layerName.stringValue == roadLayerName.stringValue || layerName.stringValue == landuseLayerName.stringValue) && subTypeValues!=null)
|
||||
//{
|
||||
// maskValue.intValue = EditorGUILayout.MaskField("Type",maskValue.intValue, subTypeValues);
|
||||
// string selectedOptions = string.Empty;
|
||||
// for (int i = 0; i < subTypeValues.Length; i++)
|
||||
// {
|
||||
// if ((maskValue.intValue & (1 << i)) == (1 << i))
|
||||
// {
|
||||
// if (string.IsNullOrEmpty(selectedOptions))
|
||||
// {
|
||||
// selectedOptions = subTypeValues[i];
|
||||
// continue;
|
||||
// }
|
||||
// selectedOptions += "," + subTypeValues[i];
|
||||
// }
|
||||
// }
|
||||
// selectedTypes.stringValue = selectedOptions;
|
||||
//}
|
||||
//*********************** TYPE DROPDOWN ENDS ***********************************//
|
||||
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
//*********************** FILTERS SECTION BEGINS ***********************************//
|
||||
var filterOptions = layerProperty.FindPropertyRelative("filterOptions");
|
||||
filterOptions.FindPropertyRelative("_selectedLayerName").stringValue = subLayerCoreOptions.FindPropertyRelative("layerName").stringValue;
|
||||
GUILayout.Space(-_lineHeight);
|
||||
EditorGUILayout.PropertyField(filterOptions, new GUIContent("Filters"));
|
||||
//*********************** FILTERS SECTION ENDS ***********************************//
|
||||
|
||||
|
||||
|
||||
//*********************** MODELING SECTION BEGINS ***********************************//
|
||||
_modelingSectionDrawer.DrawUI(subLayerCoreOptions, layerProperty, primitiveTypeProp);
|
||||
//*********************** MODELING SECTION ENDS ***********************************//
|
||||
|
||||
|
||||
//*********************** TEXTURING SECTION BEGINS ***********************************//
|
||||
if (primitiveTypeProp != VectorPrimitiveType.Point && primitiveTypeProp != VectorPrimitiveType.Custom)
|
||||
{
|
||||
GUILayout.Space(-_lineHeight);
|
||||
EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("materialOptions"));
|
||||
}
|
||||
//*********************** TEXTURING SECTION ENDS ***********************************//
|
||||
|
||||
|
||||
//*********************** GAMEPLAY SECTION BEGINS ***********************************//
|
||||
_behaviorModifierSectionDrawer.DrawUI(layerProperty, primitiveTypeProp, sourceType);
|
||||
//*********************** GAMEPLAY SECTION ENDS ***********************************//
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
private void LoadEditorTileJSON(SerializedProperty property, VectorSourceType sourceTypeValue, string sourceString)
|
||||
{
|
||||
if (sourceTypeValue != VectorSourceType.None && !string.IsNullOrEmpty(sourceString))
|
||||
{
|
||||
if (tileJSONResponse == null || string.IsNullOrEmpty(sourceString) || sourceString != TilesetId)
|
||||
{
|
||||
//tileJSONData.ClearData();
|
||||
try
|
||||
{
|
||||
Unity.MapboxAccess.Instance.TileJSON.Get(sourceString, (response) =>
|
||||
{
|
||||
//if the code has reached this point it means that there is a valid access token
|
||||
tileJSONResponse = response;
|
||||
if (response == null || response.VectorLayers == null) //indicates bad tileresponse
|
||||
{
|
||||
tileJSONData.ClearData();
|
||||
return;
|
||||
}
|
||||
tileJSONData.ProcessTileJSONData(response);
|
||||
});
|
||||
}
|
||||
catch (System.Exception)
|
||||
{
|
||||
//no valid access token causes MapboxAccess to throw an error and hence setting this property
|
||||
tileJSONData.ClearData();
|
||||
}
|
||||
}
|
||||
else if (tileJSONData.LayerPropertyDescriptionDictionary.Count == 0)
|
||||
{
|
||||
tileJSONData.ProcessTileJSONData(tileJSONResponse);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tileJSONData.ClearData();
|
||||
}
|
||||
TilesetId = sourceString;
|
||||
}
|
||||
|
||||
public void DrawLayerName(SerializedProperty property, List<string> layerDisplayNames)
|
||||
{
|
||||
|
||||
var layerNameLabel = new GUIContent
|
||||
{
|
||||
text = "Data Layer",
|
||||
tooltip = "The layer name from the Mapbox tileset that would be used for visualizing a feature"
|
||||
};
|
||||
|
||||
//disable the selection if there is no layer
|
||||
if (layerDisplayNames.Count == 0)
|
||||
{
|
||||
EditorGUILayout.LabelField(layerNameLabel, new GUIContent("No layers found: Invalid MapId / No Internet."), (GUIStyle)"minipopUp");
|
||||
return;
|
||||
}
|
||||
|
||||
//check the string value at the current _layerIndex to verify that the stored index matches the property string.
|
||||
var layerString = property.FindPropertyRelative("layerName").stringValue;
|
||||
if (layerDisplayNames.Contains(layerString))
|
||||
{
|
||||
//if the layer contains the current layerstring, set it's index to match
|
||||
_layerIndex = layerDisplayNames.FindIndex(s => s.Equals(layerString));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//if the selected layer isn't in the source, add a placeholder entry
|
||||
_layerIndex = 0;
|
||||
layerDisplayNames.Insert(0, layerString);
|
||||
if (!tileJsonData.LayerPropertyDescriptionDictionary.ContainsKey(layerString))
|
||||
{
|
||||
tileJsonData.LayerPropertyDescriptionDictionary.Add(layerString, new Dictionary<string, string>());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//create the display name guicontent array with an additional entry for the currently selected item
|
||||
_layerTypeContent = new GUIContent[layerDisplayNames.Count];
|
||||
for (int extIdx = 0; extIdx < layerDisplayNames.Count; extIdx++)
|
||||
{
|
||||
_layerTypeContent[extIdx] = new GUIContent
|
||||
{
|
||||
text = layerDisplayNames[extIdx],
|
||||
};
|
||||
}
|
||||
|
||||
//draw the layer selection popup
|
||||
_layerIndex = EditorGUILayout.Popup(layerNameLabel, _layerIndex, _layerTypeContent);
|
||||
var parsedString = layerDisplayNames.ToArray()[_layerIndex].Split(new string[] { tileJsonData.commonLayersKey }, System.StringSplitOptions.None)[0].Trim();
|
||||
property.FindPropertyRelative("layerName").stringValue = parsedString;
|
||||
}
|
||||
|
||||
private string[] GetSubTypeValues(SerializedProperty layerProperty, string visualizerLayer, VectorSourceType sourceType)
|
||||
{
|
||||
string[] typesArray = null;
|
||||
string roadLayer = layerProperty.FindPropertyRelative("roadLayer").stringValue;
|
||||
string landuseLayer = layerProperty.FindPropertyRelative("landuseLayer").stringValue;
|
||||
|
||||
if (visualizerLayer == roadLayer || visualizerLayer == landuseLayer)
|
||||
{
|
||||
_streetsV7TileStats = TileStatsFetcher.Instance.GetTileStats(sourceType);
|
||||
if (_streetsV7TileStats != null && _streetsV7TileStats.layers != null && _streetsV7TileStats.layers.Length != 0)
|
||||
{
|
||||
foreach (var layer in _streetsV7TileStats.layers)
|
||||
{
|
||||
if (layer.layer != visualizerLayer)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
string presetPropertyName = "";
|
||||
if (layer.layer == roadLayer)
|
||||
{
|
||||
presetPropertyName = layerProperty.FindPropertyRelative("roadLayer_TypeProperty").stringValue;
|
||||
}
|
||||
else if (layer.layer == landuseLayer)
|
||||
{
|
||||
presetPropertyName = layerProperty.FindPropertyRelative("landuseLayer_TypeProperty").stringValue;
|
||||
}
|
||||
|
||||
if (layer.attributes != null && layer.attributes.Length > 0)
|
||||
{
|
||||
foreach (var attributeItem in layer.attributes)
|
||||
{
|
||||
if (attributeItem.attribute == presetPropertyName)
|
||||
{
|
||||
typesArray = attributeItem.values;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return typesArray;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a49c4311b159a483a8d3a61c78ac50bf
|
||||
timeCreated: 1525818948
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,242 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Mapbox.Unity.Map;
|
||||
using Mapbox.VectorTile.ExtensionMethods;
|
||||
using System.Linq;
|
||||
using Mapbox.Platform.TilesetTileJSON;
|
||||
using System.Collections.Generic;
|
||||
using Mapbox.Editor;
|
||||
|
||||
[CustomPropertyDrawer(typeof(GeometryExtrusionOptions))]
|
||||
public class GeometryExtrusionOptionsDrawer : PropertyDrawer
|
||||
{
|
||||
//indices for tileJSON lookup
|
||||
int _propertyIndex = 0;
|
||||
private static List<string> _propertyNamesList = new List<string>();
|
||||
GUIContent[] _propertyNameContent;
|
||||
|
||||
GUIContent[] extrusionTypeContent;
|
||||
bool isGUIContentSet = false;
|
||||
static TileJsonData tileJsonData = new TileJsonData();
|
||||
static TileJSONResponse tileJsonResponse;
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
//property.serializedObject.Update();
|
||||
var extrusionTypeProperty = property.FindPropertyRelative("extrusionType");
|
||||
var displayNames = extrusionTypeProperty.enumDisplayNames;
|
||||
int count = extrusionTypeProperty.enumDisplayNames.Length;
|
||||
|
||||
if (!isGUIContentSet)
|
||||
{
|
||||
extrusionTypeContent = new GUIContent[count];
|
||||
for (int extIdx = 0; extIdx < count; extIdx++)
|
||||
{
|
||||
extrusionTypeContent[extIdx] = new GUIContent
|
||||
{
|
||||
text = displayNames[extIdx],
|
||||
tooltip = EnumExtensions.Description((ExtrusionType)extIdx),
|
||||
};
|
||||
}
|
||||
isGUIContentSet = true;
|
||||
}
|
||||
|
||||
var extrusionTypeLabel = new GUIContent
|
||||
{
|
||||
text = "Extrusion Type",
|
||||
tooltip = "Type of geometry extrusion"
|
||||
};
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
extrusionTypeProperty.enumValueIndex = EditorGUILayout.Popup(extrusionTypeLabel, extrusionTypeProperty.enumValueIndex, extrusionTypeContent);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(property);
|
||||
}
|
||||
|
||||
var sourceTypeValue = (Unity.Map.ExtrusionType)extrusionTypeProperty.enumValueIndex;
|
||||
|
||||
var minHeightProperty = property.FindPropertyRelative("minimumHeight");
|
||||
var maxHeightProperty = property.FindPropertyRelative("maximumHeight");
|
||||
|
||||
var extrusionGeometryType = property.FindPropertyRelative("extrusionGeometryType");
|
||||
var extrusionGeometryGUI = new GUIContent { text = "Geometry Type", tooltip = EnumExtensions.Description((Unity.Map.ExtrusionGeometryType)extrusionGeometryType.enumValueIndex) };
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
switch (sourceTypeValue)
|
||||
{
|
||||
case Unity.Map.ExtrusionType.None:
|
||||
break;
|
||||
case Unity.Map.ExtrusionType.PropertyHeight:
|
||||
EditorGUILayout.PropertyField(extrusionGeometryType, extrusionGeometryGUI);
|
||||
DrawPropertyDropDown(property, position);
|
||||
break;
|
||||
case Unity.Map.ExtrusionType.MinHeight:
|
||||
EditorGUILayout.PropertyField(extrusionGeometryType, extrusionGeometryGUI);
|
||||
DrawPropertyDropDown(property, position);
|
||||
break;
|
||||
case Unity.Map.ExtrusionType.MaxHeight:
|
||||
EditorGUILayout.PropertyField(extrusionGeometryType, extrusionGeometryGUI);
|
||||
DrawPropertyDropDown(property, position);
|
||||
break;
|
||||
case Unity.Map.ExtrusionType.RangeHeight:
|
||||
EditorGUILayout.PropertyField(extrusionGeometryType, extrusionGeometryGUI);
|
||||
DrawPropertyDropDown(property, position);
|
||||
EditorGUILayout.PropertyField(minHeightProperty);
|
||||
EditorGUILayout.PropertyField(maxHeightProperty);
|
||||
if (minHeightProperty.floatValue > maxHeightProperty.floatValue)
|
||||
{
|
||||
EditorGUILayout.HelpBox("Maximum Height less than Minimum Height!", MessageType.Error);
|
||||
}
|
||||
break;
|
||||
case Unity.Map.ExtrusionType.AbsoluteHeight:
|
||||
EditorGUILayout.PropertyField(extrusionGeometryType, extrusionGeometryGUI);
|
||||
EditorGUILayout.PropertyField(maxHeightProperty, new GUIContent { text = "Height" });
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(property);
|
||||
}
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(property.FindPropertyRelative("extrusionScaleFactor"), new GUIContent { text = "Scale Factor" });
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(property);
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
private void DrawPropertyDropDown(SerializedProperty property, Rect position)
|
||||
{
|
||||
var selectedLayerName = property.FindPropertyRelative("_selectedLayerName").stringValue;
|
||||
|
||||
var serializedMapObject = property.serializedObject;
|
||||
AbstractMap mapObject = (AbstractMap)serializedMapObject.targetObject;
|
||||
tileJsonData = mapObject.VectorData.GetTileJsonData();
|
||||
|
||||
DrawPropertyName(property, position, selectedLayerName);
|
||||
}
|
||||
|
||||
private void DrawPropertyName(SerializedProperty property, Rect position, string selectedLayerName)
|
||||
{
|
||||
var parsedString = "No property selected";
|
||||
var descriptionString = "No description available";
|
||||
|
||||
if (string.IsNullOrEmpty(selectedLayerName) || tileJsonData == null || !tileJsonData.PropertyDisplayNames.ContainsKey(selectedLayerName))
|
||||
{
|
||||
DrawWarningMessage(position);
|
||||
}
|
||||
else
|
||||
{
|
||||
var propertyDisplayNames = tileJsonData.PropertyDisplayNames[selectedLayerName];
|
||||
_propertyNamesList = new List<string>(propertyDisplayNames);
|
||||
|
||||
//check if the selection is valid
|
||||
var propertyString = property.FindPropertyRelative("propertyName").stringValue;
|
||||
if (_propertyNamesList.Contains(propertyString))
|
||||
{
|
||||
//if the layer contains the current layerstring, set it's index to match
|
||||
_propertyIndex = propertyDisplayNames.FindIndex(s => s.Equals(propertyString));
|
||||
|
||||
|
||||
//create guicontent for a valid layer
|
||||
_propertyNameContent = new GUIContent[_propertyNamesList.Count];
|
||||
for (int extIdx = 0; extIdx < _propertyNamesList.Count; extIdx++)
|
||||
{
|
||||
var parsedPropertyString = _propertyNamesList[extIdx].Split(new string[] { tileJsonData.optionalPropertiesString }, System.StringSplitOptions.None)[0].Trim();
|
||||
_propertyNameContent[extIdx] = new GUIContent
|
||||
{
|
||||
text = _propertyNamesList[extIdx],
|
||||
tooltip = tileJsonData.LayerPropertyDescriptionDictionary[selectedLayerName][parsedPropertyString]
|
||||
};
|
||||
}
|
||||
|
||||
//display popup
|
||||
var propertyNameLabel = new GUIContent { text = "Property Name", tooltip = "The name of the property in the selected Mapbox layer that will be used for extrusion" };
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
_propertyIndex = EditorGUILayout.Popup(propertyNameLabel, _propertyIndex, _propertyNameContent);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(property);
|
||||
}
|
||||
|
||||
//set new string values based on selection
|
||||
parsedString = _propertyNamesList[_propertyIndex].Split(new string[] { tileJsonData.optionalPropertiesString }, System.StringSplitOptions.None)[0].Trim();
|
||||
descriptionString = tileJsonData.LayerPropertyDescriptionDictionary[selectedLayerName][parsedString];
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//if the selected layer isn't in the source, add a placeholder entry
|
||||
_propertyIndex = 0;
|
||||
_propertyNamesList.Insert(0, propertyString);
|
||||
|
||||
//create guicontent for an invalid layer
|
||||
_propertyNameContent = new GUIContent[_propertyNamesList.Count];
|
||||
|
||||
//first property gets a unique tooltip
|
||||
_propertyNameContent[0] = new GUIContent
|
||||
{
|
||||
text = _propertyNamesList[0],
|
||||
tooltip = "Unavialable in Selected Layer"
|
||||
};
|
||||
|
||||
for (int extIdx = 1; extIdx < _propertyNamesList.Count; extIdx++)
|
||||
{
|
||||
var parsedPropertyString = _propertyNamesList[extIdx].Split(new string[] { tileJsonData.optionalPropertiesString }, System.StringSplitOptions.None)[0].Trim();
|
||||
_propertyNameContent[extIdx] = new GUIContent
|
||||
{
|
||||
text = _propertyNamesList[extIdx],
|
||||
tooltip = tileJsonData.LayerPropertyDescriptionDictionary[selectedLayerName][parsedPropertyString]
|
||||
};
|
||||
}
|
||||
|
||||
//display popup
|
||||
var propertyNameLabel = new GUIContent { text = "Property Name", tooltip = "The name of the property in the selected Mapbox layer that will be used for extrusion" };
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
_propertyIndex = EditorGUILayout.Popup(propertyNameLabel, _propertyIndex, _propertyNameContent);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(property);
|
||||
}
|
||||
|
||||
//set new string values based on the offset
|
||||
parsedString = _propertyNamesList[_propertyIndex].Split(new string[] { tileJsonData.optionalPropertiesString }, System.StringSplitOptions.None)[0].Trim();
|
||||
descriptionString = "Unavailable in Selected Layer.";
|
||||
|
||||
}
|
||||
|
||||
property.FindPropertyRelative("propertyName").stringValue = parsedString;
|
||||
property.FindPropertyRelative("propertyDescription").stringValue = descriptionString;
|
||||
|
||||
}
|
||||
|
||||
descriptionString = string.IsNullOrEmpty(descriptionString) ? "No description available" : descriptionString;
|
||||
|
||||
var propertyDescriptionPrefixLabel = new GUIContent { text = "Property Description", tooltip = "Factual information about the selected property" };
|
||||
EditorGUILayout.LabelField(propertyDescriptionPrefixLabel, new GUIContent(descriptionString), (GUIStyle)"wordWrappedLabel");
|
||||
}
|
||||
|
||||
private void DrawWarningMessage(Rect position)
|
||||
{
|
||||
GUIStyle labelStyle = new GUIStyle(EditorStyles.popup);
|
||||
//labelStyle.normal.textColor = Color.red;
|
||||
labelStyle.fontStyle = FontStyle.Bold;
|
||||
var layerNameLabel = new GUIContent { text = "Property Name", tooltip = "The name of the property in the selected Mapbox layer that will be used for extrusion" };
|
||||
EditorGUILayout.LabelField(layerNameLabel, new GUIContent("No properties found in layer"), labelStyle);//(GUIStyle)"minipopUp");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d66413ab6b7d648e2ba3cfd4e1d72382
|
||||
timeCreated: 1521052834
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,239 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Mapbox.Unity;
|
||||
using Mapbox.Editor;
|
||||
using Mapbox.Unity.Map;
|
||||
using Mapbox.Unity.MeshGeneration.Data;
|
||||
using Mapbox.VectorTile.ExtensionMethods;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class StyleIconBundle
|
||||
{
|
||||
public string path;
|
||||
public Texture texture;
|
||||
public void Load()
|
||||
{
|
||||
if (texture == null)
|
||||
{
|
||||
texture = Resources.Load(path) as Texture;
|
||||
}
|
||||
}
|
||||
|
||||
public StyleIconBundle(string styleName, string paletteName = "")
|
||||
{
|
||||
path = Path.Combine(Constants.Path.MAP_FEATURE_STYLES_SAMPLES, Path.Combine(styleName, string.Format("{0}Icon", (styleName + paletteName))));
|
||||
}
|
||||
}
|
||||
|
||||
[CustomPropertyDrawer(typeof(GeometryMaterialOptions))]
|
||||
public class GeometryMaterialOptionsDrawer : PropertyDrawer
|
||||
{
|
||||
static float lineHeight = EditorGUIUtility.singleLineHeight;
|
||||
private string objectId = "";
|
||||
bool showTexturing
|
||||
{
|
||||
get
|
||||
{
|
||||
return EditorPrefs.GetBool(objectId + "VectorSubLayerProperties_showTexturing");
|
||||
}
|
||||
set
|
||||
{
|
||||
EditorPrefs.SetBool(objectId + "VectorSubLayerProperties_showTexturing", value);
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<StyleTypes, StyleIconBundle> _styleIconBundles = new Dictionary<StyleTypes, StyleIconBundle>()
|
||||
{
|
||||
{StyleTypes.Simple, new StyleIconBundle(StyleTypes.Simple.ToString())},
|
||||
{StyleTypes.Realistic, new StyleIconBundle(StyleTypes.Realistic.ToString())},
|
||||
{StyleTypes.Fantasy, new StyleIconBundle(StyleTypes.Fantasy.ToString())},
|
||||
{StyleTypes.Light, new StyleIconBundle(StyleTypes.Light.ToString())},
|
||||
{StyleTypes.Dark, new StyleIconBundle(StyleTypes.Dark.ToString())},
|
||||
{StyleTypes.Color, new StyleIconBundle(StyleTypes.Color.ToString())},
|
||||
{StyleTypes.Satellite, new StyleIconBundle(StyleTypes.Satellite.ToString())},
|
||||
};
|
||||
|
||||
private Dictionary<SamplePalettes, StyleIconBundle> _paletteIconBundles = new Dictionary<SamplePalettes, StyleIconBundle>()
|
||||
{
|
||||
{SamplePalettes.City, new StyleIconBundle(StyleTypes.Simple.ToString(), SamplePalettes.City.ToString())},
|
||||
{SamplePalettes.Cool, new StyleIconBundle(StyleTypes.Simple.ToString(), SamplePalettes.Cool.ToString())},
|
||||
{SamplePalettes.Rainbow, new StyleIconBundle(StyleTypes.Simple.ToString(), SamplePalettes.Rainbow.ToString())},
|
||||
{SamplePalettes.Urban, new StyleIconBundle(StyleTypes.Simple.ToString(), SamplePalettes.Urban.ToString())},
|
||||
{SamplePalettes.Warm, new StyleIconBundle(StyleTypes.Simple.ToString(), SamplePalettes.Warm.ToString())},
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Loads the default style icons.
|
||||
/// </summary>
|
||||
|
||||
private void LoadDefaultStyleIcons()
|
||||
{
|
||||
foreach (var key in _styleIconBundles.Keys)
|
||||
{
|
||||
_styleIconBundles[key].Load();
|
||||
}
|
||||
foreach (var key in _paletteIconBundles.Keys)
|
||||
{
|
||||
_paletteIconBundles[key].Load();
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
|
||||
objectId = property.serializedObject.targetObject.GetInstanceID().ToString();
|
||||
|
||||
showTexturing = EditorGUILayout.Foldout(showTexturing, new GUIContent { text = "Texturing", tooltip = "Material options to texture the generated building geometry" });
|
||||
if (showTexturing)
|
||||
{
|
||||
LoadDefaultStyleIcons();
|
||||
EditorGUI.BeginProperty(position, label, property);
|
||||
|
||||
var styleTypeLabel = new GUIContent { text = "Style Type", tooltip = "Texturing style for feature; choose from sample style or create your own by choosing Custom. " };
|
||||
var styleType = property.FindPropertyRelative("style");
|
||||
|
||||
GUIContent[] styleTypeGuiContent = new GUIContent[styleType.enumDisplayNames.Length];
|
||||
for (int i = 0; i < styleType.enumDisplayNames.Length; i++)
|
||||
{
|
||||
styleTypeGuiContent[i] = new GUIContent
|
||||
{
|
||||
text = styleType.enumDisplayNames[i]
|
||||
};
|
||||
}
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
styleType.enumValueIndex = EditorGUILayout.Popup(styleTypeLabel, styleType.enumValueIndex, styleTypeGuiContent);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(property);
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel++;
|
||||
if ((StyleTypes)styleType.enumValueIndex != StyleTypes.Custom)
|
||||
{
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
var style = (StyleTypes)styleType.enumValueIndex;
|
||||
|
||||
Texture2D thumbnailTexture = (Texture2D)_styleIconBundles[style].texture;
|
||||
|
||||
if ((StyleTypes)styleType.enumValueIndex == StyleTypes.Simple)
|
||||
{
|
||||
var samplePaletteType = property.FindPropertyRelative("samplePalettes");
|
||||
var palette = (SamplePalettes)samplePaletteType.enumValueIndex;
|
||||
thumbnailTexture = (Texture2D)_paletteIconBundles[palette].texture;
|
||||
}
|
||||
|
||||
string descriptionLabel = EnumExtensions.Description(style);
|
||||
EditorGUILayout.LabelField(new GUIContent(" ", thumbnailTexture), Constants.GUI.Styles.EDITOR_TEXTURE_THUMBNAIL_STYLE, GUILayout.Height(60), GUILayout.Width(EditorGUIUtility.labelWidth - 60));
|
||||
EditorGUILayout.TextArea(descriptionLabel, (GUIStyle)"wordWrappedLabel");
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
switch ((StyleTypes)styleType.enumValueIndex)
|
||||
{
|
||||
case StyleTypes.Simple:
|
||||
var samplePaletteType = property.FindPropertyRelative("samplePalettes");
|
||||
var samplePaletteTypeLabel = new GUIContent { text = "Palette Type", tooltip = "Palette type for procedural colorization; choose from sample palettes or create your own by choosing Custom. " };
|
||||
|
||||
GUIContent[] samplePaletteTypeGuiContent = new GUIContent[samplePaletteType.enumDisplayNames.Length];
|
||||
for (int i = 0; i < samplePaletteType.enumDisplayNames.Length; i++)
|
||||
{
|
||||
samplePaletteTypeGuiContent[i] = new GUIContent
|
||||
{
|
||||
text = samplePaletteType.enumDisplayNames[i]
|
||||
};
|
||||
}
|
||||
samplePaletteType.enumValueIndex = EditorGUILayout.Popup(samplePaletteTypeLabel, samplePaletteType.enumValueIndex, samplePaletteTypeGuiContent);
|
||||
break;
|
||||
case StyleTypes.Light:
|
||||
property.FindPropertyRelative("lightStyleOpacity").floatValue = EditorGUILayout.Slider("Opacity", property.FindPropertyRelative("lightStyleOpacity").floatValue, 0.0f, 1.0f);
|
||||
break;
|
||||
case StyleTypes.Dark:
|
||||
property.FindPropertyRelative("darkStyleOpacity").floatValue = EditorGUILayout.Slider("Opacity", property.FindPropertyRelative("darkStyleOpacity").floatValue, 0.0f, 1.0f);
|
||||
break;
|
||||
case StyleTypes.Color:
|
||||
property.FindPropertyRelative("colorStyleColor").colorValue = EditorGUILayout.ColorField("Color", property.FindPropertyRelative("colorStyleColor").colorValue);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(property);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var customStyleProperty = property.FindPropertyRelative("customStyleOptions");
|
||||
var texturingType = customStyleProperty.FindPropertyRelative("texturingType");
|
||||
|
||||
int valIndex = texturingType.enumValueIndex == 0 ? 0 : texturingType.enumValueIndex + 1;
|
||||
var texturingTypeGUI = new GUIContent { text = "Texturing Type", tooltip = EnumExtensions.Description((UvMapType)valIndex) };
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(texturingType, texturingTypeGUI);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(property);
|
||||
}
|
||||
|
||||
var matList = customStyleProperty.FindPropertyRelative("materials");
|
||||
if (matList.arraySize == 0)
|
||||
{
|
||||
matList.arraySize = 2;
|
||||
}
|
||||
GUILayout.Space(-lineHeight);
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(matList.GetArrayElementAtIndex(0), new GUIContent { text = "Top Material", tooltip = "Unity material to use for extruded top/roof mesh. " });
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(property);
|
||||
}
|
||||
|
||||
|
||||
GUILayout.Space(-lineHeight);
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(matList.GetArrayElementAtIndex(1), new GUIContent { text = "Side Material", tooltip = "Unity material to use for extruded side/wall mesh. " });
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(property);
|
||||
}
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
if ((UvMapType)texturingType.enumValueIndex + 1 == UvMapType.Atlas)
|
||||
{
|
||||
var atlasInfo = customStyleProperty.FindPropertyRelative("atlasInfo");
|
||||
EditorGUILayout.ObjectField(atlasInfo, new GUIContent { text = "Altas Info", tooltip = "Atlas information scriptable object, this defines how the texture roof and wall texture atlases will be used. " });
|
||||
}
|
||||
if ((UvMapType)texturingType.enumValueIndex + 1 == UvMapType.AtlasWithColorPalette)
|
||||
{
|
||||
var atlasInfo = customStyleProperty.FindPropertyRelative("atlasInfo");
|
||||
EditorGUILayout.ObjectField(atlasInfo, new GUIContent { text = "Altas Info", tooltip = "Atlas information scriptable object, this defines how the texture roof and wall texture atlases will be used. " });
|
||||
|
||||
var colorPalette = customStyleProperty.FindPropertyRelative("colorPalette");
|
||||
EditorGUILayout.ObjectField(colorPalette, new GUIContent { text = "Color Palette", tooltip = "Color palette scriptable object, allows texture features to be procedurally colored at runtime. Requires materials that use the MapboxPerRenderer shader. " });
|
||||
|
||||
EditorGUILayout.LabelField(new GUIContent { text = "Note: Atlas With Color Palette requires materials that use the MapboxPerRenderer shader." }, Constants.GUI.Styles.EDITOR_NOTE_STYLE);
|
||||
}
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(property);
|
||||
}
|
||||
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
EditorGUI.EndProperty();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e8e9adb2cd7094d48acbefb75a01436b
|
||||
timeCreated: 1521052834
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,97 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Mapbox.Unity.Map;
|
||||
using Mapbox.VectorTile.ExtensionMethods;
|
||||
|
||||
[CustomPropertyDrawer(typeof(ImageryLayerProperties))]
|
||||
public class ImageryLayerPropertiesDrawer : PropertyDrawer
|
||||
{
|
||||
GUIContent[] sourceTypeContent;
|
||||
bool isGUIContentSet = false;
|
||||
|
||||
private GUIContent _mapIdGui = new GUIContent
|
||||
{
|
||||
text = "Map Id",
|
||||
tooltip = "Map Id corresponding to the tileset."
|
||||
};
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
var sourceTypeProperty = property.FindPropertyRelative("sourceType");
|
||||
var sourceTypeValue = (ImagerySourceType)sourceTypeProperty.enumValueIndex;
|
||||
|
||||
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 = EnumExtensions.Description((ImagerySourceType)extIdx),
|
||||
};
|
||||
}
|
||||
isGUIContentSet = true;
|
||||
}
|
||||
|
||||
// Draw label.
|
||||
var sourceTypeLabel = new GUIContent { text = "Data Source", tooltip = "Source tileset for Imagery." };
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
sourceTypeProperty.enumValueIndex = EditorGUILayout.Popup(sourceTypeLabel, sourceTypeProperty.enumValueIndex, sourceTypeContent);
|
||||
if(EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(property);
|
||||
}
|
||||
sourceTypeValue = (ImagerySourceType)sourceTypeProperty.enumValueIndex;
|
||||
|
||||
var sourceOptionsProperty = property.FindPropertyRelative("sourceOptions");
|
||||
var layerSourceProperty = sourceOptionsProperty.FindPropertyRelative("layerSource");
|
||||
var layerSourceId = layerSourceProperty.FindPropertyRelative("Id");
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
switch (sourceTypeValue)
|
||||
{
|
||||
case ImagerySourceType.MapboxStreets:
|
||||
case ImagerySourceType.MapboxOutdoors:
|
||||
case ImagerySourceType.MapboxDark:
|
||||
case ImagerySourceType.MapboxLight:
|
||||
case ImagerySourceType.MapboxSatellite:
|
||||
case ImagerySourceType.MapboxSatelliteStreet:
|
||||
var sourcePropertyValue = MapboxDefaultImagery.GetParameters(sourceTypeValue);
|
||||
layerSourceId.stringValue = sourcePropertyValue.Id;
|
||||
GUI.enabled = false;
|
||||
EditorGUILayout.PropertyField(sourceOptionsProperty, _mapIdGui);
|
||||
GUI.enabled = true;
|
||||
break;
|
||||
case ImagerySourceType.Custom:
|
||||
EditorGUILayout.PropertyField(sourceOptionsProperty, new GUIContent { text = "Map Id / Style URL", tooltip = _mapIdGui.tooltip });
|
||||
break;
|
||||
case ImagerySourceType.None:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(property);
|
||||
}
|
||||
|
||||
if (sourceTypeValue != ImagerySourceType.None)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(property.FindPropertyRelative("rasterOptions"));
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(property);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8d00c4bf63fb7481bba0b0a96c4e9b03
|
||||
timeCreated: 1517889179
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,57 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Mapbox.Unity.Map;
|
||||
|
||||
[CustomPropertyDrawer(typeof(ImageryRasterOptions))]
|
||||
public class ImageryRasterOptionsDrawer : PropertyDrawer
|
||||
{
|
||||
static float lineHeight = EditorGUIUtility.singleLineHeight;
|
||||
bool showPosition = true;
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
EditorGUI.BeginProperty(position, label, property);
|
||||
position.height = lineHeight;
|
||||
foreach (var item in property)
|
||||
{
|
||||
var subproperty = item as SerializedProperty;
|
||||
EditorGUI.PropertyField(position, subproperty, true);
|
||||
position.height = lineHeight;
|
||||
position.y += lineHeight;
|
||||
}
|
||||
|
||||
EditorGUI.EndProperty();
|
||||
}
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
int rows = (showPosition) ? 3 : 1;
|
||||
return (float)rows * lineHeight;
|
||||
}
|
||||
}
|
||||
|
||||
//[CustomPropertyDrawer(typeof(TypeVisualizerTuple))]
|
||||
//public class TypeVisualizerBaseDrawer : PropertyDrawer
|
||||
//{
|
||||
// static float lineHeight = EditorGUIUtility.singleLineHeight;
|
||||
// bool showPosition = true;
|
||||
// public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
// {
|
||||
// EditorGUI.BeginProperty(position, label, property);
|
||||
|
||||
// position.height = lineHeight;
|
||||
|
||||
// EditorGUI.PropertyField(position, property.FindPropertyRelative("Stack"));
|
||||
|
||||
// EditorGUI.EndProperty();
|
||||
// }
|
||||
// public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
// {
|
||||
// // Reserve space for the total visible properties.
|
||||
// int rows = 2;
|
||||
// //Debug.Log("Height - " + rows * lineHeight);
|
||||
// return (float)rows * lineHeight;
|
||||
// }
|
||||
//}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6eff4b0718ee34d37913417f65afad08
|
||||
timeCreated: 1521052834
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,26 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Mapbox.Unity.Map;
|
||||
|
||||
[CustomPropertyDrawer(typeof(LayerPerformanceOptions))]
|
||||
public class LayerPerformanceOptionsDrawer : PropertyDrawer
|
||||
{
|
||||
SerializedProperty isActiveProperty;
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
isActiveProperty = property.FindPropertyRelative("isEnabled");
|
||||
|
||||
isActiveProperty.boolValue = EditorGUILayout.Toggle(new GUIContent("Enable Coroutines"), isActiveProperty.boolValue);
|
||||
|
||||
if (isActiveProperty.boolValue == true)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(property.FindPropertyRelative("entityPerCoroutine"), true);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 16db3da0a971247e79b6bb10e0d26862
|
||||
timeCreated: 1521052834
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,24 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Mapbox.Unity.Map;
|
||||
|
||||
[CustomPropertyDrawer(typeof(LayerSourceOptions))]
|
||||
public class LayerSourceOptionsDrawer : PropertyDrawer
|
||||
{
|
||||
static float lineHeight = EditorGUIUtility.singleLineHeight;
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
EditorGUI.BeginProperty(position, label, property);
|
||||
position.height = lineHeight;
|
||||
EditorGUI.PropertyField(position, property.FindPropertyRelative("layerSource"), label);
|
||||
EditorGUI.EndProperty();
|
||||
}
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
return lineHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 66a87ffd5023a4fbe889f65e3fdcb4ac
|
||||
timeCreated: 1521052834
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,26 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Mapbox.Unity.Map;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System;
|
||||
using Mapbox.VectorTile.ExtensionMethods;
|
||||
|
||||
[CustomPropertyDrawer(typeof(LineGeometryOptions))]
|
||||
public class LineGeometryOptionsDrawer : PropertyDrawer
|
||||
{
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
EditorGUILayout.PropertyField(property.FindPropertyRelative("Width"));
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(property);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 81806f31401d69747ba09bd8aa3e4c73
|
||||
timeCreated: 1537464920
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,75 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Mapbox.Unity.Map;
|
||||
using Mapbox.VectorTile.ExtensionMethods;
|
||||
|
||||
[CustomPropertyDrawer(typeof(MapExtentOptions))]
|
||||
public class MapExtentOptionsDrawer : PropertyDrawer
|
||||
{
|
||||
static string extTypePropertyName = "extentType";
|
||||
static float _lineHeight = EditorGUIUtility.singleLineHeight;
|
||||
GUIContent[] extentTypeContent;
|
||||
bool isGUIContentSet = false;
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
var kindProperty = property.FindPropertyRelative(extTypePropertyName);
|
||||
var displayNames = kindProperty.enumDisplayNames;
|
||||
int count = kindProperty.enumDisplayNames.Length;
|
||||
if (!isGUIContentSet)
|
||||
{
|
||||
extentTypeContent = new GUIContent[count];
|
||||
for (int extIdx = 0; extIdx < count; extIdx++)
|
||||
{
|
||||
extentTypeContent[extIdx] = new GUIContent
|
||||
{
|
||||
text = displayNames[extIdx],
|
||||
tooltip = EnumExtensions.Description((MapExtentType)extIdx),
|
||||
};
|
||||
}
|
||||
isGUIContentSet = true;
|
||||
}
|
||||
// Draw label.
|
||||
var extentTypeLabel = new GUIContent
|
||||
{
|
||||
text = label.text,
|
||||
tooltip = "Options to determine the geographic extent of the world for which the map tiles will be requested.",
|
||||
};
|
||||
EditorGUI.BeginChangeCheck();
|
||||
kindProperty.enumValueIndex = EditorGUILayout.Popup(extentTypeLabel, kindProperty.enumValueIndex, extentTypeContent, GUILayout.Height(_lineHeight));
|
||||
|
||||
var kind = (MapExtentType)kindProperty.enumValueIndex;
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(property);
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
GUILayout.Space(-_lineHeight);
|
||||
SerializedProperty defaultExtentsProp = property.FindPropertyRelative("defaultExtents");
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
switch (kind)
|
||||
{
|
||||
case MapExtentType.CameraBounds:
|
||||
EditorGUILayout.PropertyField(defaultExtentsProp.FindPropertyRelative("cameraBoundsOptions"), new GUIContent { text = "CameraOptions-" });
|
||||
break;
|
||||
case MapExtentType.RangeAroundCenter:
|
||||
EditorGUILayout.PropertyField(defaultExtentsProp.FindPropertyRelative("rangeAroundCenterOptions"), new GUIContent { text = "RangeAroundCenter" });
|
||||
break;
|
||||
case MapExtentType.RangeAroundTransform:
|
||||
EditorGUILayout.PropertyField(defaultExtentsProp.FindPropertyRelative("rangeAroundTransformOptions"), new GUIContent { text = "RangeAroundTransform" });
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(defaultExtentsProp);
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 61582b113819848348a7a1a629916371
|
||||
timeCreated: 1517858264
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,32 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Mapbox.Unity.Map;
|
||||
|
||||
[CustomPropertyDrawer(typeof(MapLocationOptions))]
|
||||
public class MapLocationOptionsDrawer : PropertyDrawer
|
||||
{
|
||||
static float _lineHeight = EditorGUIUtility.singleLineHeight;
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
GUILayout.Space(-1f * _lineHeight);
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(property.FindPropertyRelative("latitudeLongitude"));
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(property);
|
||||
}
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(property.FindPropertyRelative("zoom"), GUILayout.Height(_lineHeight));
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(property);
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cba048f4ed8d1458e88aee6ae0ae4226
|
||||
timeCreated: 1521052834
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,78 @@
|
||||
using Mapbox.Unity.Map.TileProviders;
|
||||
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Mapbox.Unity.Map;
|
||||
[CustomPropertyDrawer(typeof(MapOptions))]
|
||||
public class MapOptionsDrawer : PropertyDrawer
|
||||
{
|
||||
static float lineHeight = EditorGUIUtility.singleLineHeight;
|
||||
bool showPosition = false;
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
EditorGUI.BeginProperty(position, label, property);
|
||||
|
||||
position.height = lineHeight;
|
||||
EditorGUI.LabelField(position, "Location ");
|
||||
position.y += lineHeight;
|
||||
EditorGUILayout.PropertyField(property.FindPropertyRelative("locationOptions"));
|
||||
position.y += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("locationOptions"));
|
||||
var extentOptions = property.FindPropertyRelative("extentOptions");
|
||||
var extentOptionsType = extentOptions.FindPropertyRelative("extentType");
|
||||
if ((MapExtentType)extentOptionsType.enumValueIndex == MapExtentType.Custom)
|
||||
{
|
||||
var test = property.serializedObject.FindProperty("_tileProvider");
|
||||
|
||||
EditorGUI.PropertyField(position, test);
|
||||
position.y += lineHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUI.PropertyField(position, property.FindPropertyRelative("extentOptions"));
|
||||
|
||||
position.y += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("extentOptions"));
|
||||
}
|
||||
|
||||
showPosition = EditorGUI.Foldout(position, showPosition, "Others");
|
||||
if (showPosition)
|
||||
{
|
||||
position.y += lineHeight;
|
||||
EditorGUILayout.PropertyField(property.FindPropertyRelative("placementOptions"));
|
||||
|
||||
position.y += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("placementOptions"));
|
||||
EditorGUI.PropertyField(position, property.FindPropertyRelative("scalingOptions"));
|
||||
|
||||
}
|
||||
EditorGUI.EndProperty();
|
||||
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
// Reserve space for the total visible properties.
|
||||
float height = 2.0f * lineHeight;
|
||||
if (showPosition)
|
||||
{
|
||||
height += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("placementOptions"));
|
||||
height += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("scalingOptions"));
|
||||
}
|
||||
height += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("locationOptions"));
|
||||
height += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("extentOptions"));
|
||||
return height;
|
||||
}
|
||||
}
|
||||
|
||||
[CustomPropertyDrawer(typeof(AbstractTileProvider))]
|
||||
public class AbstractTileProviderDrawer : PropertyDrawer
|
||||
{
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
EditorGUI.BeginProperty(position, label, property);
|
||||
EditorGUI.ObjectField(position, property);
|
||||
EditorGUI.EndProperty();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9f76f257073bf49efbf18d1e75531f2a
|
||||
timeCreated: 1520010402
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,38 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Mapbox.Unity.Map;
|
||||
using Mapbox.VectorTile.ExtensionMethods;
|
||||
|
||||
[CustomPropertyDrawer(typeof(MapPlacementOptions))]
|
||||
public class MapPlacementOptionsDrawer : PropertyDrawer
|
||||
{
|
||||
GUIContent[] placementTypeContent;
|
||||
bool isGUIContentSet = false;
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
var placementType = property.FindPropertyRelative("placementType");
|
||||
var snapMapToTerrain = property.FindPropertyRelative("snapMapToZero");
|
||||
|
||||
var displayNames = placementType.enumDisplayNames;
|
||||
int count = placementType.enumDisplayNames.Length;
|
||||
if (!isGUIContentSet)
|
||||
{
|
||||
placementTypeContent = new GUIContent[count];
|
||||
for (int extIdx = 0; extIdx < count; extIdx++)
|
||||
{
|
||||
placementTypeContent[extIdx] = new GUIContent
|
||||
{
|
||||
text = displayNames[extIdx],
|
||||
tooltip = EnumExtensions.Description((MapPlacementType)extIdx),
|
||||
};
|
||||
}
|
||||
isGUIContentSet = true;
|
||||
}
|
||||
|
||||
placementType.enumValueIndex = EditorGUILayout.Popup(new GUIContent { text = label.text, tooltip = "Placement of Map root.", }, placementType.enumValueIndex, placementTypeContent);
|
||||
EditorGUILayout.PropertyField(snapMapToTerrain, new GUIContent { text = snapMapToTerrain.displayName, tooltip = "If checked, map's root will be snapped to zero. " });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5156142fbca0a4c7bbc4b5949bd9a004
|
||||
timeCreated: 1521052834
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,46 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Mapbox.Unity.Map;
|
||||
using Mapbox.VectorTile.ExtensionMethods;
|
||||
|
||||
[CustomPropertyDrawer(typeof(MapScalingOptions))]
|
||||
public class MapScalingOptionsDrawer : PropertyDrawer
|
||||
{
|
||||
static float lineHeight = EditorGUIUtility.singleLineHeight;
|
||||
GUIContent[] scalingTypeContent;
|
||||
bool isGUIContentSet = false;
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
var scalingType = property.FindPropertyRelative("scalingType");
|
||||
var displayNames = scalingType.enumDisplayNames;
|
||||
int count = scalingType.enumDisplayNames.Length;
|
||||
if (!isGUIContentSet)
|
||||
{
|
||||
scalingTypeContent = new GUIContent[count];
|
||||
for (int extIdx = 0; extIdx < count; extIdx++)
|
||||
{
|
||||
scalingTypeContent[extIdx] = new GUIContent
|
||||
{
|
||||
text = displayNames[extIdx],
|
||||
tooltip = EnumExtensions.Description((MapScalingType)extIdx),
|
||||
};
|
||||
}
|
||||
isGUIContentSet = true;
|
||||
}
|
||||
|
||||
// Draw label.
|
||||
var scalingTypeLabel = new GUIContent { text = label.text, tooltip = "Scale of map in game units.", };
|
||||
|
||||
scalingType.enumValueIndex = EditorGUILayout.Popup(scalingTypeLabel, scalingType.enumValueIndex, scalingTypeContent);
|
||||
|
||||
if ((MapScalingType)scalingType.enumValueIndex == MapScalingType.Custom)
|
||||
{
|
||||
position.y += lineHeight;
|
||||
EditorGUILayout.PropertyField(property.FindPropertyRelative("unityTileSize"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3273da310cf694e0982177c792acf843
|
||||
timeCreated: 1521052834
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,22 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Mapbox.Unity.MeshGeneration.Modifiers;
|
||||
|
||||
[CustomPropertyDrawer(typeof(MaterialList))]
|
||||
public class MaterialListDrawer : PropertyDrawer
|
||||
{
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
EditorGUI.BeginProperty(position, label, property);
|
||||
var matArray = property.FindPropertyRelative("Materials");
|
||||
if (matArray.arraySize == 0)
|
||||
{
|
||||
matArray.arraySize = 1;
|
||||
}
|
||||
EditorGUILayout.PropertyField(property.FindPropertyRelative("Materials").GetArrayElementAtIndex(0), label);
|
||||
EditorGUI.EndProperty();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ac4d01f35c9334c9f90ce5c57523f06c
|
||||
timeCreated: 1521052834
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,93 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEditor;
|
||||
using Mapbox.Unity.Map;
|
||||
using Mapbox.Editor;
|
||||
using Mapbox.Unity.MeshGeneration.Modifiers;
|
||||
|
||||
public class ModelingSectionDrawer
|
||||
{
|
||||
private string objectId = "";
|
||||
bool showModeling
|
||||
{
|
||||
get
|
||||
{
|
||||
return EditorPrefs.GetBool(objectId + "VectorSubLayerProperties_showModeling");
|
||||
}
|
||||
set
|
||||
{
|
||||
EditorPrefs.SetBool(objectId + "VectorSubLayerProperties_showModeling", value);
|
||||
}
|
||||
}
|
||||
static float _lineHeight = EditorGUIUtility.singleLineHeight;
|
||||
|
||||
public void DrawUI(SerializedProperty subLayerCoreOptions, SerializedProperty layerProperty, VectorPrimitiveType primitiveTypeProp)
|
||||
{
|
||||
|
||||
objectId = layerProperty.serializedObject.targetObject.GetInstanceID().ToString();
|
||||
|
||||
EditorGUILayout.BeginVertical();
|
||||
showModeling = EditorGUILayout.Foldout(showModeling, new GUIContent { text = "Modeling", tooltip = "This section provides you with options to fine tune your meshes" });
|
||||
if (showModeling)
|
||||
{
|
||||
GUILayout.Space(-_lineHeight);
|
||||
EditorGUILayout.PropertyField(subLayerCoreOptions);
|
||||
|
||||
if (primitiveTypeProp == VectorPrimitiveType.Line)
|
||||
{
|
||||
GUILayout.Space(-_lineHeight);
|
||||
var lineGeometryOptions = layerProperty.FindPropertyRelative("lineGeometryOptions");
|
||||
EditorGUILayout.PropertyField(lineGeometryOptions);
|
||||
}
|
||||
|
||||
if (primitiveTypeProp != VectorPrimitiveType.Point && primitiveTypeProp != VectorPrimitiveType.Custom)
|
||||
{
|
||||
GUILayout.Space(-_lineHeight);
|
||||
var extrusionOptions = layerProperty.FindPropertyRelative("extrusionOptions");
|
||||
extrusionOptions.FindPropertyRelative("_selectedLayerName").stringValue = subLayerCoreOptions.FindPropertyRelative("layerName").stringValue;
|
||||
EditorGUILayout.PropertyField(extrusionOptions);
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
var snapToTerrainProperty = subLayerCoreOptions.FindPropertyRelative("snapToTerrain");
|
||||
snapToTerrainProperty.boolValue = EditorGUILayout.Toggle(snapToTerrainProperty.displayName, snapToTerrainProperty.boolValue);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(subLayerCoreOptions);
|
||||
}
|
||||
}
|
||||
|
||||
if (primitiveTypeProp != VectorPrimitiveType.Point)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
var combineMeshesProperty = subLayerCoreOptions.FindPropertyRelative("combineMeshes");
|
||||
combineMeshesProperty.boolValue = EditorGUILayout.Toggle(combineMeshesProperty.displayName, combineMeshesProperty.boolValue);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(subLayerCoreOptions);
|
||||
}
|
||||
}
|
||||
|
||||
if (primitiveTypeProp != VectorPrimitiveType.Point && primitiveTypeProp != VectorPrimitiveType.Custom)
|
||||
{
|
||||
GUILayout.Space(-_lineHeight);
|
||||
|
||||
var colliderOptionsProperty = layerProperty.FindPropertyRelative("colliderOptions");
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(colliderOptionsProperty);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
Debug.Log("Collider UI changed");
|
||||
EditorHelper.CheckForModifiedProperty(colliderOptionsProperty);
|
||||
}
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 39f85c0d2d7cb4b5e989cf0edd7109a9
|
||||
timeCreated: 1529620234
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,235 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using Mapbox.Editor;
|
||||
using UnityEditor.IMGUI.Controls;
|
||||
using System.Linq;
|
||||
|
||||
public class PointsOfInterestSubLayerPropertiesDrawer
|
||||
{
|
||||
string objectId = "";
|
||||
static float _lineHeight = EditorGUIUtility.singleLineHeight;
|
||||
|
||||
//PointsOfInterestSubLayerTreeView layerTreeView = new PointsOfInterestSubLayerTreeView(new TreeViewState());
|
||||
FeatureSubLayerTreeView layerTreeView;// = new FeatureSubLayerTreeView
|
||||
IList<int> selectedLayers = new List<int>();
|
||||
|
||||
private TreeModel<FeatureTreeElement> treeModel;
|
||||
[SerializeField]
|
||||
TreeViewState m_TreeViewState;
|
||||
|
||||
[SerializeField]
|
||||
MultiColumnHeaderState m_MultiColumnHeaderState;
|
||||
|
||||
bool m_Initialized = false;
|
||||
|
||||
int SelectionIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return EditorPrefs.GetInt(objectId + "LocationPrefabsLayerProperties_selectionIndex");
|
||||
}
|
||||
set
|
||||
{
|
||||
EditorPrefs.SetInt(objectId + "LocationPrefabsLayerProperties_selectionIndex", value);
|
||||
}
|
||||
}
|
||||
|
||||
public void DrawUI(SerializedProperty property)
|
||||
{
|
||||
objectId = property.serializedObject.targetObject.GetInstanceID().ToString();
|
||||
var prefabItemArray = property.FindPropertyRelative("locationPrefabList");
|
||||
var layersRect = EditorGUILayout.GetControlRect(GUILayout.MinHeight(Mathf.Max(prefabItemArray.arraySize + 1, 1) * _lineHeight + MultiColumnHeader.DefaultGUI.defaultHeight),
|
||||
GUILayout.MaxHeight((prefabItemArray.arraySize + 1) * _lineHeight + MultiColumnHeader.DefaultGUI.defaultHeight));
|
||||
|
||||
if (!m_Initialized)
|
||||
{
|
||||
bool firstInit = m_MultiColumnHeaderState == null;
|
||||
var headerState = FeatureSubLayerTreeView.CreateDefaultMultiColumnHeaderState();
|
||||
if (MultiColumnHeaderState.CanOverwriteSerializedFields(m_MultiColumnHeaderState, headerState))
|
||||
{
|
||||
MultiColumnHeaderState.OverwriteSerializedFields(m_MultiColumnHeaderState, headerState);
|
||||
}
|
||||
m_MultiColumnHeaderState = headerState;
|
||||
|
||||
var multiColumnHeader = new FeatureSectionMultiColumnHeader(headerState);
|
||||
|
||||
if (firstInit)
|
||||
{
|
||||
multiColumnHeader.ResizeToFit();
|
||||
}
|
||||
|
||||
treeModel = new TreeModel<FeatureTreeElement>(GetData(prefabItemArray));
|
||||
if (m_TreeViewState == null)
|
||||
{
|
||||
m_TreeViewState = new TreeViewState();
|
||||
}
|
||||
|
||||
if (layerTreeView == null)
|
||||
{
|
||||
layerTreeView = new FeatureSubLayerTreeView(m_TreeViewState, multiColumnHeader, treeModel, FeatureSubLayerTreeView.uniqueIdPoI);
|
||||
}
|
||||
layerTreeView.multiColumnHeader = multiColumnHeader;
|
||||
m_Initialized = true;
|
||||
}
|
||||
|
||||
|
||||
layerTreeView.Layers = prefabItemArray;
|
||||
layerTreeView.Reload();
|
||||
layerTreeView.OnGUI(layersRect);
|
||||
|
||||
if (layerTreeView.hasChanged)
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(property);
|
||||
layerTreeView.hasChanged = false;
|
||||
}
|
||||
|
||||
selectedLayers = layerTreeView.GetSelection();
|
||||
//if there are selected elements, set the selection index at the first element.
|
||||
//if not, use the Selection index to persist the selection at the right index.
|
||||
if (selectedLayers.Count > 0)
|
||||
{
|
||||
//ensure that selectedLayers[0] isn't out of bounds
|
||||
if (selectedLayers[0] - FeatureSubLayerTreeView.uniqueIdPoI > prefabItemArray.arraySize - 1)
|
||||
{
|
||||
selectedLayers[0] = prefabItemArray.arraySize - 1 + FeatureSubLayerTreeView.uniqueIdPoI;
|
||||
}
|
||||
|
||||
SelectionIndex = selectedLayers[0];
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
selectedLayers = new int[1] { SelectionIndex };
|
||||
if (SelectionIndex > 0 && (SelectionIndex - FeatureSubLayerTreeView.uniqueIdPoI <= prefabItemArray.arraySize - 1))
|
||||
{
|
||||
layerTreeView.SetSelection(selectedLayers);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GUILayout.Space(EditorGUIUtility.singleLineHeight);
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
|
||||
if (GUILayout.Button(new GUIContent("Add Layer"), (GUIStyle)"minibuttonleft"))
|
||||
{
|
||||
|
||||
//GUILayout.Space(EditorGUIUtility.singleLineHeight);
|
||||
prefabItemArray.arraySize++;
|
||||
|
||||
var prefabItem = prefabItemArray.GetArrayElementAtIndex(prefabItemArray.arraySize - 1);
|
||||
var prefabItemName = prefabItem.FindPropertyRelative("coreOptions.sublayerName");
|
||||
|
||||
prefabItemName.stringValue = "New Location";
|
||||
|
||||
// Set defaults here because SerializedProperty copies the previous element.
|
||||
prefabItem.FindPropertyRelative("coreOptions.isActive").boolValue = true;
|
||||
prefabItem.FindPropertyRelative("coreOptions.snapToTerrain").boolValue = true;
|
||||
prefabItem.FindPropertyRelative("presetFeatureType").enumValueIndex = (int)PresetFeatureType.Points;
|
||||
var categories = prefabItem.FindPropertyRelative("categories");
|
||||
categories.intValue = (int)(LocationPrefabCategories.AnyCategory);//To select any category option
|
||||
|
||||
var density = prefabItem.FindPropertyRelative("density");
|
||||
density.intValue = 15;//To select all locations option
|
||||
|
||||
//Refreshing the tree
|
||||
layerTreeView.Layers = prefabItemArray;
|
||||
layerTreeView.AddElementToTree(prefabItem);
|
||||
layerTreeView.Reload();
|
||||
|
||||
selectedLayers = new int[1] { prefabItemArray.arraySize - 1 };
|
||||
layerTreeView.SetSelection(selectedLayers);
|
||||
|
||||
if (EditorHelper.DidModifyProperty(property))
|
||||
{
|
||||
PrefabItemOptions prefabItemOptionToAdd = (PrefabItemOptions)EditorHelper.GetTargetObjectOfProperty(prefabItem) as PrefabItemOptions;
|
||||
((VectorLayerProperties)EditorHelper.GetTargetObjectOfProperty(property)).OnSubLayerPropertyAdded(new VectorLayerUpdateArgs { property = prefabItemOptionToAdd });
|
||||
}
|
||||
}
|
||||
|
||||
if (GUILayout.Button(new GUIContent("Remove Selected"), (GUIStyle)"minibuttonright"))
|
||||
{
|
||||
foreach (var index in selectedLayers.OrderByDescending(i => i))
|
||||
{
|
||||
if (layerTreeView != null)
|
||||
{
|
||||
var poiSubLayer = prefabItemArray.GetArrayElementAtIndex(index - FeatureSubLayerTreeView.uniqueIdPoI);
|
||||
|
||||
VectorLayerProperties vectorLayerProperties = (VectorLayerProperties)EditorHelper.GetTargetObjectOfProperty(property);
|
||||
PrefabItemOptions poiSubLayerProperties = (PrefabItemOptions)EditorHelper.GetTargetObjectOfProperty(poiSubLayer);
|
||||
|
||||
vectorLayerProperties.OnSubLayerPropertyRemoved(new VectorLayerUpdateArgs { property = poiSubLayerProperties });
|
||||
|
||||
layerTreeView.RemoveItemFromTree(index);
|
||||
prefabItemArray.DeleteArrayElementAtIndex(index - FeatureSubLayerTreeView.uniqueIdPoI);
|
||||
layerTreeView.treeModel.SetData(GetData(prefabItemArray));
|
||||
}
|
||||
}
|
||||
selectedLayers = new int[0];
|
||||
layerTreeView.SetSelection(selectedLayers);
|
||||
}
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
if (selectedLayers.Count == 1 && prefabItemArray.arraySize != 0 && selectedLayers[0] - FeatureSubLayerTreeView.uniqueIdPoI >= 0)
|
||||
{
|
||||
//ensure that selectedLayers[0] isn't out of bounds
|
||||
if (selectedLayers[0] - FeatureSubLayerTreeView.uniqueIdPoI > prefabItemArray.arraySize - 1)
|
||||
{
|
||||
selectedLayers[0] = prefabItemArray.arraySize - 1 + FeatureSubLayerTreeView.uniqueIdPoI;
|
||||
}
|
||||
SelectionIndex = selectedLayers[0];
|
||||
|
||||
var layerProperty = prefabItemArray.GetArrayElementAtIndex(SelectionIndex - FeatureSubLayerTreeView.uniqueIdPoI);
|
||||
|
||||
layerProperty.isExpanded = true;
|
||||
var subLayerCoreOptions = layerProperty.FindPropertyRelative("coreOptions");
|
||||
bool isLayerActive = subLayerCoreOptions.FindPropertyRelative("isActive").boolValue;
|
||||
if (!isLayerActive)
|
||||
{
|
||||
GUI.enabled = false;
|
||||
}
|
||||
DrawLayerLocationPrefabProperties(layerProperty, property);
|
||||
if (!isLayerActive)
|
||||
{
|
||||
GUI.enabled = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GUILayout.Space(15);
|
||||
GUILayout.Label("Select a visualizer to see properties");
|
||||
}
|
||||
}
|
||||
|
||||
void DrawLayerLocationPrefabProperties(SerializedProperty layerProperty, SerializedProperty property)
|
||||
{
|
||||
EditorGUILayout.PropertyField(layerProperty);
|
||||
}
|
||||
|
||||
IList<FeatureTreeElement> GetData(SerializedProperty subLayerArray)
|
||||
{
|
||||
List<FeatureTreeElement> elements = new List<FeatureTreeElement>();
|
||||
string name = string.Empty;
|
||||
string type = string.Empty;
|
||||
int id = 0;
|
||||
var root = new FeatureTreeElement("Root", -1, 0);
|
||||
elements.Add(root);
|
||||
for (int i = 0; i < subLayerArray.arraySize; i++)
|
||||
{
|
||||
var subLayer = subLayerArray.GetArrayElementAtIndex(i);
|
||||
name = subLayer.FindPropertyRelative("coreOptions.sublayerName").stringValue;
|
||||
id = i + FeatureSubLayerTreeView.uniqueIdPoI;
|
||||
type = PresetFeatureType.Points.ToString();//((PresetFeatureType)subLayer.FindPropertyRelative("presetFeatureType").enumValueIndex).ToString();
|
||||
FeatureTreeElement element = new FeatureTreeElement(name, 0, id);
|
||||
element.Name = name;
|
||||
element.name = name;
|
||||
element.Type = type;
|
||||
elements.Add(element);
|
||||
}
|
||||
return elements;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 20fb110d2102743939c89f5a3ab9c3a4
|
||||
timeCreated: 1525818946
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,223 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using UnityEngine;
|
||||
using Mapbox.Unity.Map;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Mapbox.VectorTile.ExtensionMethods;
|
||||
|
||||
[CustomPropertyDrawer(typeof(PrefabItemOptions))]
|
||||
public class PrefabItemOptionsDrawer : PropertyDrawer
|
||||
{
|
||||
|
||||
static float _lineHeight = EditorGUIUtility.singleLineHeight;
|
||||
const string searchButtonContent = "Search";
|
||||
|
||||
private GUIContent prefabLocationsTitle = new GUIContent
|
||||
{
|
||||
text = "Prefab Locations",
|
||||
tooltip = "Where on the map to spawn the selected prefab"
|
||||
};
|
||||
|
||||
|
||||
private GUIContent findByDropDown = new GUIContent
|
||||
{
|
||||
text = "Find by",
|
||||
tooltip = "Find points-of-interest by category, name, or address"
|
||||
};
|
||||
|
||||
private GUIContent categoriesDropDown = new GUIContent
|
||||
{
|
||||
text = "Category",
|
||||
tooltip = "Spawn at locations in the categories selected"
|
||||
};
|
||||
|
||||
private GUIContent densitySlider = new GUIContent
|
||||
{
|
||||
text = "Density",
|
||||
tooltip = "The number of prefabs to spawn per-tile; try a lower number if the map is cluttered"
|
||||
};
|
||||
|
||||
private GUIContent nameField = new GUIContent
|
||||
{
|
||||
text = "Name",
|
||||
tooltip = "Spawn at locations containing this name string"
|
||||
};
|
||||
|
||||
GUIContent[] findByPropContent;
|
||||
bool isGUIContentSet = false;
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
GUILayout.Space(-_lineHeight);
|
||||
var prefabItemCoreOptions = property.FindPropertyRelative("coreOptions");
|
||||
GUILayout.Label(prefabItemCoreOptions.FindPropertyRelative("sublayerName").stringValue + " Properties");
|
||||
|
||||
//Prefab Game Object
|
||||
EditorGUI.indentLevel++;
|
||||
var spawnPrefabOptions = property.FindPropertyRelative("spawnPrefabOptions");
|
||||
|
||||
EditorGUILayout.PropertyField(spawnPrefabOptions);
|
||||
|
||||
GUILayout.Space(1);
|
||||
EditorGUI.indentLevel--;
|
||||
|
||||
//Prefab Locations title
|
||||
GUILayout.Label(prefabLocationsTitle);
|
||||
|
||||
//FindBy drop down
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
|
||||
var findByProp = property.FindPropertyRelative("findByType");
|
||||
|
||||
var displayNames = findByProp.enumDisplayNames;
|
||||
int count = findByProp.enumDisplayNames.Length;
|
||||
if (!isGUIContentSet)
|
||||
{
|
||||
findByPropContent = new GUIContent[count];
|
||||
for (int extIdx = 0; extIdx < count; extIdx++)
|
||||
{
|
||||
findByPropContent[extIdx] = new GUIContent
|
||||
{
|
||||
text = displayNames[extIdx],
|
||||
tooltip = ((LocationPrefabFindBy)extIdx).Description(),
|
||||
};
|
||||
}
|
||||
isGUIContentSet = true;
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
findByProp.enumValueIndex = EditorGUILayout.Popup(findByDropDown, findByProp.enumValueIndex, findByPropContent);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(property);
|
||||
}
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
switch ((LocationPrefabFindBy)findByProp.enumValueIndex)
|
||||
{
|
||||
case (LocationPrefabFindBy.MapboxCategory):
|
||||
ShowCategoryOptions(property);
|
||||
break;
|
||||
case (LocationPrefabFindBy.AddressOrLatLon):
|
||||
ShowAddressOrLatLonUI(property);
|
||||
break;
|
||||
case (LocationPrefabFindBy.POIName):
|
||||
ShowPOINames(property);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
private void ShowCategoryOptions(SerializedProperty property)
|
||||
{
|
||||
//Category drop down
|
||||
EditorGUI.BeginChangeCheck();
|
||||
var categoryProp = property.FindPropertyRelative("categories");
|
||||
categoryProp.intValue = (int)(LocationPrefabCategories)(EditorGUILayout.EnumFlagsField(categoriesDropDown, (LocationPrefabCategories)categoryProp.intValue));
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(property);
|
||||
}
|
||||
ShowDensitySlider(property);
|
||||
}
|
||||
|
||||
private void ShowAddressOrLatLonUI(SerializedProperty property)
|
||||
{
|
||||
//EditorGUILayout.BeginVertical();
|
||||
var coordinateProperties = property.FindPropertyRelative("coordinates");
|
||||
|
||||
for (int i = 0; i < coordinateProperties.arraySize; i++)
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
//get the element to draw
|
||||
var coordinate = coordinateProperties.GetArrayElementAtIndex(i);
|
||||
|
||||
//label for each location.
|
||||
var coordinateLabel = String.Format("Location {0}", i);
|
||||
|
||||
// draw coordinate string.
|
||||
EditorGUI.BeginChangeCheck();
|
||||
coordinate.stringValue = EditorGUILayout.TextField(coordinateLabel, coordinate.stringValue);
|
||||
|
||||
if(EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(property, true);
|
||||
}
|
||||
// draw search button.
|
||||
if (GUILayout.Button(new GUIContent(searchButtonContent), (GUIStyle)"minibuttonleft", GUILayout.MaxWidth(100)))
|
||||
{
|
||||
object propertyObject = EditorHelper.GetTargetObjectOfProperty(property);
|
||||
GeocodeAttributeSearchWindow.Open(coordinate, propertyObject);
|
||||
}
|
||||
|
||||
//include a remove button in the row
|
||||
if (GUILayout.Button(new GUIContent(" X "), (GUIStyle)"minibuttonright", GUILayout.MaxWidth(30)))
|
||||
{
|
||||
coordinateProperties.DeleteArrayElementAtIndex(i);
|
||||
EditorHelper.CheckForModifiedProperty(property);
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
GUILayout.Space(EditorGUIUtility.labelWidth - 3);
|
||||
|
||||
if (GUILayout.Button(new GUIContent("Add Location"), (GUIStyle)"minibutton"))
|
||||
{
|
||||
coordinateProperties.arraySize++;
|
||||
var newElement = coordinateProperties.GetArrayElementAtIndex(coordinateProperties.arraySize - 1);
|
||||
newElement.stringValue = "";
|
||||
EditorHelper.CheckForModifiedProperty(property);
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
|
||||
private void ShowPOINames(SerializedProperty property)
|
||||
{
|
||||
//Name field
|
||||
var categoryProp = property.FindPropertyRelative("nameString");
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
categoryProp.stringValue = EditorGUILayout.TextField(nameField, categoryProp.stringValue);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(property);
|
||||
}
|
||||
|
||||
ShowDensitySlider(property);
|
||||
}
|
||||
|
||||
private void ShowDensitySlider(SerializedProperty property)
|
||||
{
|
||||
//Density slider
|
||||
var densityProp = property.FindPropertyRelative("density");
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(densityProp, densitySlider);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(property);
|
||||
}
|
||||
GUI.enabled = true;
|
||||
densityProp.serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
private Rect GetNewRect(Rect position)
|
||||
{
|
||||
return new Rect(position.x, position.y, position.width, _lineHeight);
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
return _lineHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e267a35441e2f4c19a4b96c23afad4ae
|
||||
timeCreated: 1523396148
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,23 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Mapbox.Unity.Map;
|
||||
|
||||
[CustomPropertyDrawer(typeof(RangeAroundTransformTileProviderOptions))]
|
||||
public class RangeAroundTransformTileProviderOptionsDrawer : PropertyDrawer
|
||||
{
|
||||
static float lineHeight = EditorGUIUtility.singleLineHeight;
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
foreach (var item in property)
|
||||
{
|
||||
var subproperty = item as SerializedProperty;
|
||||
EditorGUILayout.PropertyField(subproperty, true);
|
||||
position.height = lineHeight;
|
||||
position.y += lineHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 758132744af3642f2ae9a7c31ce9c0d9
|
||||
timeCreated: 1521052834
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,22 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Mapbox.Unity.Map;
|
||||
|
||||
[CustomPropertyDrawer(typeof(RangeTileProviderOptions))]
|
||||
public class RangeTileProviderOptionsDrawer : PropertyDrawer
|
||||
{
|
||||
static float lineHeight = EditorGUIUtility.singleLineHeight;
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
foreach (var item in property)
|
||||
{
|
||||
var subproperty = item as SerializedProperty;
|
||||
EditorGUILayout.PropertyField(subproperty, true);
|
||||
position.height = lineHeight;
|
||||
position.y += lineHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 59524ff7910c146abad051df9ab054db
|
||||
timeCreated: 1521052834
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,47 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Mapbox.Unity.MeshGeneration.Modifiers;
|
||||
using UnityEditor;
|
||||
using Mapbox.Editor;
|
||||
|
||||
[CustomPropertyDrawer(typeof(SpawnPrefabOptions))]
|
||||
public class SpawnPrefabOptionsDrawer : PropertyDrawer
|
||||
{
|
||||
static float lineHeight = EditorGUIUtility.singleLineHeight;
|
||||
|
||||
private GUIContent prefabContent = new GUIContent
|
||||
{
|
||||
text = "Prefab",
|
||||
tooltip = "The prefab to be spawned"
|
||||
};
|
||||
|
||||
private GUIContent scalePrefabContent = new GUIContent
|
||||
{
|
||||
text = "Scale down with world",
|
||||
tooltip = "The prefab will scale with the map object"
|
||||
};
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
EditorGUI.BeginProperty(position, label, property);
|
||||
position.height = 2.5f * lineHeight;
|
||||
EditorGUI.BeginChangeCheck();
|
||||
property.FindPropertyRelative("prefab").objectReferenceValue = EditorGUI.ObjectField(new Rect(position.x, position.y, position.width, lineHeight), prefabContent, property.FindPropertyRelative("prefab").objectReferenceValue, typeof(UnityEngine.GameObject), false);
|
||||
position.y += lineHeight;
|
||||
EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("scaleDownWithWorld"), scalePrefabContent);
|
||||
if(EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(property);
|
||||
}
|
||||
EditorGUI.EndProperty();
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
return 2.0f * lineHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d2da764c4c82845efbcea6530b3c8120
|
||||
timeCreated: 1523922185
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,23 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Mapbox.Unity.Map;
|
||||
|
||||
[CustomPropertyDrawer(typeof(Style))]
|
||||
public class StyleOptionsDrawer : PropertyDrawer
|
||||
{
|
||||
static float lineHeight = EditorGUIUtility.singleLineHeight;
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
GUILayout.Space(-lineHeight);
|
||||
EditorGUILayout.PropertyField(property.FindPropertyRelative("Id"), label);
|
||||
}
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
// Reserve space for the total visible properties.
|
||||
return lineHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 971e17905b31043f3914e1efda0ef7d7
|
||||
timeCreated: 1521052834
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,57 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using Mapbox.Unity.Utilities;
|
||||
using Mapbox.Unity;
|
||||
|
||||
/// <summary>
|
||||
/// Custom property drawer for style searching. <para/>
|
||||
/// Includes a search window to enable listing of styles associated with a username.
|
||||
/// Requires a Mapbox token be set for the project.
|
||||
/// </summary>
|
||||
[CustomPropertyDrawer(typeof(StyleSearchAttribute))]
|
||||
public class StyleSearchAttributeDrawer : PropertyDrawer
|
||||
{
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
|
||||
EditorGUILayout.HelpBox("Style Id and Modified date is required for optimized tileset feature. You can copy&paste those values from Styles page under your Mapbox Account or use the search feature to fetch them automatically.", MessageType.Info);
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
|
||||
var id = property.FindPropertyRelative("Id");
|
||||
|
||||
var name = property.FindPropertyRelative("Name");
|
||||
var modified = property.FindPropertyRelative("Modified");
|
||||
|
||||
id.stringValue = EditorGUILayout.TextField("Style Id: ", id.stringValue);
|
||||
name.stringValue = EditorGUILayout.TextField("Name: ", name.stringValue);
|
||||
modified.stringValue = EditorGUILayout.TextField("Modified: ", modified.stringValue);
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
if (string.IsNullOrEmpty(MapboxAccess.Instance.Configuration.AccessToken))
|
||||
{
|
||||
GUI.enabled = false;
|
||||
GUILayout.Button("Need Mapbox Access Token");
|
||||
GUI.enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GUILayout.Button("Search"))
|
||||
{
|
||||
StyleSearchWindow.Open(property);
|
||||
}
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Clear", GUILayout.Width(100)))
|
||||
{
|
||||
id.stringValue = "";
|
||||
name.stringValue = "";
|
||||
modified.stringValue = "";
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ecd235e0566324c96b4039ca60f6b2fe
|
||||
timeCreated: 1500479391
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,27 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Mapbox.Unity.Map;
|
||||
|
||||
[CustomPropertyDrawer(typeof(TerrainColliderOptions))]
|
||||
public class TerrainColliderOptionsDrawer : PropertyDrawer
|
||||
{
|
||||
static float lineHeight = EditorGUIUtility.singleLineHeight;
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
EditorGUI.BeginProperty(position, label, property);
|
||||
|
||||
position.y += lineHeight;
|
||||
EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("addCollider"));
|
||||
|
||||
EditorGUI.EndProperty();
|
||||
}
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
// Reserve space for the total visible properties.
|
||||
return 3.0f * lineHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2749f8cef0c9ccc4b9f4ca3c94f34a4b
|
||||
timeCreated: 1521052834
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,41 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Mapbox.Unity.Map;
|
||||
|
||||
[CustomPropertyDrawer(typeof(TerrainSideWallOptions))]
|
||||
public class TerrainSideWallOptionsDrawer : PropertyDrawer
|
||||
{
|
||||
static float lineHeight = EditorGUIUtility.singleLineHeight;
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
var isSidewallActiveProp = property.FindPropertyRelative("isActive");
|
||||
EditorGUI.BeginProperty(position, label, property);
|
||||
|
||||
EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), isSidewallActiveProp, new GUIContent("Show Sidewalls"));
|
||||
if (isSidewallActiveProp.boolValue == true)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
position.y += lineHeight;
|
||||
EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("wallHeight"));
|
||||
position.y += lineHeight;
|
||||
EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("wallMaterial"));
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
EditorGUI.EndProperty();
|
||||
}
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
// Reserve space for the total visible properties.
|
||||
var isSidewallActiveProp = property.FindPropertyRelative("isActive");
|
||||
if (isSidewallActiveProp.boolValue == true)
|
||||
{
|
||||
return 3.0f * lineHeight;
|
||||
}
|
||||
return 1.0f * lineHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7e18fe9e46c4e4426ae988fe03893a06
|
||||
timeCreated: 1521052834
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,35 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Mapbox.Unity.Map;
|
||||
|
||||
[CustomPropertyDrawer(typeof(UnityLayerOptions))]
|
||||
public class UnityLayerOptionsDrawer : PropertyDrawer
|
||||
{
|
||||
static float lineHeight = EditorGUIUtility.singleLineHeight;
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
var addtoLayerProp = property.FindPropertyRelative("addToLayer");
|
||||
EditorGUI.BeginProperty(position, label, property);
|
||||
|
||||
EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), addtoLayerProp, new GUIContent { text = "Add to Unity layer" });
|
||||
if (addtoLayerProp.boolValue == true)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
var layerId = property.FindPropertyRelative("layerId");
|
||||
layerId.intValue = EditorGUILayout.LayerField("Layer", layerId.intValue);
|
||||
//EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("layerId"));
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
EditorGUI.EndProperty();
|
||||
}
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
// Reserve space for the total visible properties.
|
||||
return 1.0f * lineHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bdef06805a8a74efdac863d35cbc5ea3
|
||||
timeCreated: 1521052834
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,272 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Mapbox.Unity.Map;
|
||||
using Mapbox.Unity.MeshGeneration.Filters;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
[CustomPropertyDrawer(typeof(VectorFilterOptions))]
|
||||
public class VectorFilterOptionsDrawer : PropertyDrawer
|
||||
{
|
||||
//indices for tileJSON lookup
|
||||
int _propertyIndex = 0;
|
||||
List<string> _propertyNamesList = new List<string>();
|
||||
GUIContent[] _propertyNameContent;
|
||||
|
||||
private string[] descriptionArray;
|
||||
static float lineHeight = EditorGUIUtility.singleLineHeight;
|
||||
private string objectId = "";
|
||||
bool showFilters
|
||||
{
|
||||
get
|
||||
{
|
||||
return EditorPrefs.GetBool(objectId + "VectorSubLayerProperties_showFilters");
|
||||
}
|
||||
set
|
||||
{
|
||||
EditorPrefs.SetBool(objectId + "VectorSubLayerProperties_showFilters", value);
|
||||
}
|
||||
}
|
||||
|
||||
GUIContent operatorGui = new GUIContent { text = "Operator", tooltip = "Filter operator to apply. " };
|
||||
GUIContent numValueGui = new GUIContent { text = "Num Value", tooltip = "Numeric value to match using the operator. " };
|
||||
GUIContent strValueGui = new GUIContent { text = "Str Value", tooltip = "String value to match using the operator. " };
|
||||
GUIContent minValueGui = new GUIContent { text = "Min", tooltip = "Minimum numeric value to match using the operator. " };
|
||||
GUIContent maxValueGui = new GUIContent { text = "Max", tooltip = "Maximum numeric value to match using the operator. " };
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
objectId = property.serializedObject.targetObject.GetInstanceID().ToString();
|
||||
VectorFilterOptions options = (VectorFilterOptions)EditorHelper.GetTargetObjectOfProperty(property);
|
||||
|
||||
showFilters = EditorGUILayout.Foldout(showFilters, new GUIContent { text = "Filters", tooltip = "Filter features in a vector layer based on criterion specified. " });
|
||||
if (showFilters)
|
||||
{
|
||||
var propertyFilters = property.FindPropertyRelative("filters");
|
||||
|
||||
for (int i = 0; i < propertyFilters.arraySize; i++)
|
||||
{
|
||||
DrawLayerFilter(property, propertyFilters, i, options);
|
||||
}
|
||||
if (propertyFilters.arraySize > 0)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(property.FindPropertyRelative("combinerType"));
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(property);
|
||||
}
|
||||
}
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
GUILayout.Space(EditorGUI.indentLevel * 12);
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
if (GUILayout.Button(new GUIContent("Add New Empty"), (GUIStyle)"minibutton"))
|
||||
{
|
||||
options.AddFilter();
|
||||
}
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(property);
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
return lineHeight;
|
||||
}
|
||||
|
||||
private void DrawLayerFilter(SerializedProperty originalProperty, SerializedProperty propertyFilters, int index, VectorFilterOptions vectorFilterOptions)
|
||||
{
|
||||
var property = propertyFilters.GetArrayElementAtIndex(index);
|
||||
|
||||
var filterOperatorProp = property.FindPropertyRelative("filterOperator");
|
||||
|
||||
EditorGUILayout.BeginVertical();
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
|
||||
EditorGUILayout.LabelField(new GUIContent { text = "Key", tooltip = "Name of the property to use as key. This property is case sensitive." }, GUILayout.MaxWidth(150));
|
||||
|
||||
switch ((LayerFilterOperationType)filterOperatorProp.enumValueIndex)
|
||||
{
|
||||
case LayerFilterOperationType.IsEqual:
|
||||
case LayerFilterOperationType.IsGreater:
|
||||
case LayerFilterOperationType.IsLess:
|
||||
EditorGUILayout.LabelField(operatorGui, GUILayout.MaxWidth(150));
|
||||
EditorGUILayout.LabelField(numValueGui, GUILayout.MaxWidth(100));
|
||||
break;
|
||||
case LayerFilterOperationType.Contains:
|
||||
EditorGUILayout.LabelField(operatorGui, GUILayout.MaxWidth(150));
|
||||
EditorGUILayout.LabelField(strValueGui, GUILayout.MaxWidth(100));
|
||||
break;
|
||||
case LayerFilterOperationType.IsInRange:
|
||||
EditorGUILayout.LabelField(operatorGui, GUILayout.MaxWidth(150));
|
||||
EditorGUILayout.LabelField(minValueGui, GUILayout.MaxWidth(100));
|
||||
EditorGUILayout.LabelField(maxValueGui, GUILayout.MaxWidth(100));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
|
||||
var selectedLayerName = originalProperty.FindPropertyRelative("_selectedLayerName").stringValue;
|
||||
|
||||
DrawPropertyDropDown(originalProperty, property);
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
filterOperatorProp.enumValueIndex = EditorGUILayout.Popup(filterOperatorProp.enumValueIndex, filterOperatorProp.enumDisplayNames, GUILayout.MaxWidth(150));
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(property);
|
||||
}
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
switch ((LayerFilterOperationType)filterOperatorProp.enumValueIndex)
|
||||
{
|
||||
case LayerFilterOperationType.IsEqual:
|
||||
case LayerFilterOperationType.IsGreater:
|
||||
case LayerFilterOperationType.IsLess:
|
||||
property.FindPropertyRelative("Min").doubleValue = EditorGUILayout.DoubleField(property.FindPropertyRelative("Min").doubleValue, GUILayout.MaxWidth(100));
|
||||
break;
|
||||
case LayerFilterOperationType.Contains:
|
||||
property.FindPropertyRelative("PropertyValue").stringValue = EditorGUILayout.TextField(property.FindPropertyRelative("PropertyValue").stringValue, GUILayout.MaxWidth(150));
|
||||
break;
|
||||
case LayerFilterOperationType.IsInRange:
|
||||
property.FindPropertyRelative("Min").doubleValue = EditorGUILayout.DoubleField(property.FindPropertyRelative("Min").doubleValue, GUILayout.MaxWidth(100));
|
||||
property.FindPropertyRelative("Max").doubleValue = EditorGUILayout.DoubleField(property.FindPropertyRelative("Max").doubleValue, GUILayout.MaxWidth(100));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(property);
|
||||
}
|
||||
|
||||
if (GUILayout.Button(new GUIContent(" X "), (GUIStyle)"minibuttonright", GUILayout.Width(30)))
|
||||
{
|
||||
vectorFilterOptions.RemoveFilter(index);
|
||||
}
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
private void DrawPropertyDropDown(SerializedProperty originalProperty, SerializedProperty filterProperty)
|
||||
{
|
||||
|
||||
var selectedLayerName = originalProperty.FindPropertyRelative("_selectedLayerName").stringValue;
|
||||
AbstractMap mapObject = (AbstractMap)originalProperty.serializedObject.targetObject;
|
||||
TileJsonData tileJsonData = mapObject.VectorData.GetTileJsonData();
|
||||
|
||||
if (string.IsNullOrEmpty(selectedLayerName) || !tileJsonData.PropertyDisplayNames.ContainsKey(selectedLayerName))
|
||||
{
|
||||
DrawWarningMessage();
|
||||
return;
|
||||
}
|
||||
|
||||
var parsedString = "no property selected";
|
||||
var descriptionString = "no description available";
|
||||
var propertyDisplayNames = tileJsonData.PropertyDisplayNames[selectedLayerName];
|
||||
_propertyNamesList = new List<string>(propertyDisplayNames);
|
||||
|
||||
var propertyString = filterProperty.FindPropertyRelative("Key").stringValue;
|
||||
//check if the selection is valid
|
||||
if (_propertyNamesList.Contains(propertyString))
|
||||
{
|
||||
//if the layer contains the current layerstring, set it's index to match
|
||||
_propertyIndex = propertyDisplayNames.FindIndex(s => s.Equals(propertyString));
|
||||
|
||||
//create guicontent for a valid layer
|
||||
_propertyNameContent = new GUIContent[_propertyNamesList.Count];
|
||||
for (int extIdx = 0; extIdx < _propertyNamesList.Count; extIdx++)
|
||||
{
|
||||
var parsedPropertyString = _propertyNamesList[extIdx].Split(new string[] { tileJsonData.optionalPropertiesString }, System.StringSplitOptions.None)[0].Trim();
|
||||
_propertyNameContent[extIdx] = new GUIContent
|
||||
{
|
||||
text = _propertyNamesList[extIdx],
|
||||
tooltip = tileJsonData.LayerPropertyDescriptionDictionary[selectedLayerName][parsedPropertyString]
|
||||
};
|
||||
}
|
||||
|
||||
//display popup
|
||||
EditorGUI.BeginChangeCheck();
|
||||
_propertyIndex = EditorGUILayout.Popup(_propertyIndex, _propertyNameContent, GUILayout.MaxWidth(150));
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(filterProperty);
|
||||
}
|
||||
|
||||
//set new string values based on selection
|
||||
parsedString = _propertyNamesList[_propertyIndex].Split(new string[] { tileJsonData.optionalPropertiesString }, System.StringSplitOptions.None)[0].Trim();
|
||||
descriptionString = tileJsonData.LayerPropertyDescriptionDictionary[selectedLayerName][parsedString];
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//if the selected layer isn't in the source, add a placeholder entry
|
||||
_propertyIndex = 0;
|
||||
_propertyNamesList.Insert(0, propertyString);
|
||||
|
||||
//create guicontent for an invalid layer
|
||||
_propertyNameContent = new GUIContent[_propertyNamesList.Count];
|
||||
|
||||
//first property gets a unique tooltip
|
||||
_propertyNameContent[0] = new GUIContent
|
||||
{
|
||||
text = _propertyNamesList[0],
|
||||
tooltip = "Unavialable in Selected Layer"
|
||||
};
|
||||
|
||||
for (int extIdx = 1; extIdx < _propertyNamesList.Count; extIdx++)
|
||||
{
|
||||
var parsedPropertyString = _propertyNamesList[extIdx].Split(new string[] { tileJsonData.optionalPropertiesString }, System.StringSplitOptions.None)[0].Trim();
|
||||
_propertyNameContent[extIdx] = new GUIContent
|
||||
{
|
||||
text = _propertyNamesList[extIdx],
|
||||
tooltip = tileJsonData.LayerPropertyDescriptionDictionary[selectedLayerName][parsedPropertyString]
|
||||
};
|
||||
}
|
||||
|
||||
//display popup
|
||||
EditorGUI.BeginChangeCheck();
|
||||
_propertyIndex = EditorGUILayout.Popup(_propertyIndex, _propertyNameContent, GUILayout.MaxWidth(150));
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(filterProperty);
|
||||
}
|
||||
|
||||
//set new string values based on the offset
|
||||
parsedString = _propertyNamesList[_propertyIndex].Split(new string[] { tileJsonData.optionalPropertiesString }, System.StringSplitOptions.None)[0].Trim();
|
||||
descriptionString = "Unavailable in Selected Layer.";
|
||||
|
||||
}
|
||||
EditorGUI.BeginChangeCheck();
|
||||
filterProperty.FindPropertyRelative("Key").stringValue = parsedString;
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorHelper.CheckForModifiedProperty(filterProperty);
|
||||
}
|
||||
filterProperty.FindPropertyRelative("KeyDescription").stringValue = descriptionString;
|
||||
}
|
||||
|
||||
private void DrawWarningMessage()
|
||||
{
|
||||
GUIStyle labelStyle = new GUIStyle(EditorStyles.popup);
|
||||
labelStyle.fontStyle = FontStyle.Bold;
|
||||
EditorGUILayout.LabelField(new GUIContent(), new GUIContent("No properties"), labelStyle, new GUILayoutOption[] { GUILayout.MaxWidth(155) });//(GUIStyle)"minipopUp");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 477b699ee418f4c6cb9c7896e2137c15
|
||||
timeCreated: 1521052834
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,104 @@
|
||||
namespace Mapbox.Editor
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using Mapbox.Unity.Map;
|
||||
|
||||
[CustomPropertyDrawer(typeof(VectorLayerProperties))]
|
||||
public class VectorLayerPropertiesDrawer : PropertyDrawer
|
||||
{
|
||||
private string objectId = "";
|
||||
/// <summary>
|
||||
/// Gets or sets a value to show or hide Vector section <see cref="T:Mapbox.Editor.MapManagerEditor"/>.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if show vector; otherwise, <c>false</c>.</value>
|
||||
bool ShowLocationPrefabs
|
||||
{
|
||||
get
|
||||
{
|
||||
return EditorPrefs.GetBool(objectId + "VectorLayerProperties_showLocationPrefabs");
|
||||
}
|
||||
set
|
||||
{
|
||||
EditorPrefs.SetBool(objectId + "VectorLayerProperties_showLocationPrefabs", value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value to show or hide Vector section <see cref="T:Mapbox.Editor.MapManagerEditor"/>.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if show vector; otherwise, <c>false</c>.</value>
|
||||
bool ShowFeatures
|
||||
{
|
||||
get
|
||||
{
|
||||
return EditorPrefs.GetBool(objectId + "VectorLayerProperties_showFeatures");
|
||||
}
|
||||
set
|
||||
{
|
||||
EditorPrefs.SetBool(objectId + "VectorLayerProperties_showFeatures", value);
|
||||
}
|
||||
}
|
||||
|
||||
private GUIContent _requiredMapIdGui = new GUIContent
|
||||
{
|
||||
text = "Required Map Id",
|
||||
tooltip = "For location prefabs to spawn the \"streets-v7\" tileset needs to be a part of the Vector data source"
|
||||
};
|
||||
|
||||
FeaturesSubLayerPropertiesDrawer _vectorSublayerDrawer = new FeaturesSubLayerPropertiesDrawer();
|
||||
PointsOfInterestSubLayerPropertiesDrawer _poiSublayerDrawer = new PointsOfInterestSubLayerPropertiesDrawer();
|
||||
|
||||
void ShowSepartor()
|
||||
{
|
||||
EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
EditorGUI.BeginProperty(position, null, property);
|
||||
objectId = property.serializedObject.targetObject.GetInstanceID().ToString();
|
||||
var layerSourceProperty = property.FindPropertyRelative("sourceOptions");
|
||||
var sourceTypeProperty = property.FindPropertyRelative("_sourceType");
|
||||
VectorSourceType sourceTypeValue = (VectorSourceType)sourceTypeProperty.enumValueIndex;
|
||||
string streets_v7 = MapboxDefaultVector.GetParameters(VectorSourceType.MapboxStreets).Id;
|
||||
var layerSourceId = layerSourceProperty.FindPropertyRelative("layerSource.Id");
|
||||
string layerString = layerSourceId.stringValue;
|
||||
|
||||
//Draw POI Section
|
||||
if(sourceTypeValue == VectorSourceType.None)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ShowLocationPrefabs = EditorGUILayout.Foldout(ShowLocationPrefabs, "POINTS OF INTEREST");
|
||||
if (ShowLocationPrefabs)
|
||||
{
|
||||
if (sourceTypeValue != VectorSourceType.None && layerString.Contains(streets_v7))
|
||||
{
|
||||
GUI.enabled = false;
|
||||
EditorGUILayout.TextField(_requiredMapIdGui, streets_v7);
|
||||
GUI.enabled = true;
|
||||
_poiSublayerDrawer.DrawUI(property);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.HelpBox("In order to place points of interest please add \"mapbox.mapbox-streets-v7\" to the data source.", MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
ShowSepartor();
|
||||
|
||||
//Draw Feature section.
|
||||
ShowFeatures = EditorGUILayout.Foldout(ShowFeatures, "FEATURES");
|
||||
if (ShowFeatures)
|
||||
{
|
||||
_vectorSublayerDrawer.DrawUI(property);
|
||||
}
|
||||
|
||||
EditorGUI.EndProperty();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a944f887beada4bb2966cd531f64ffe5
|
||||
timeCreated: 1518043937
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user