예제 #1
0
        public void PostProcessLayerProperties(SerializedProperty property)
        {
            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;

            if (ShowLocationPrefabs)
            {
                if (_poiSublayerDrawer.isLayerAdded == true && sourceTypeValue != VectorSourceType.None && layerString.Contains(streets_v7))
                {
                    var prefabItemArray = property.FindPropertyRelative("locationPrefabList");
                    var prefabItem      = prefabItemArray.GetArrayElementAtIndex(prefabItemArray.arraySize - 1);
                    PrefabItemOptions prefabItemOptionToAdd = (PrefabItemOptions)EditorHelper.GetTargetObjectOfProperty(prefabItem) as PrefabItemOptions;
                    ((VectorLayerProperties)EditorHelper.GetTargetObjectOfProperty(property)).OnSubLayerPropertyAdded(new VectorLayerUpdateArgs {
                        property = prefabItemOptionToAdd
                    });
                    _poiSublayerDrawer.isLayerAdded = false;
                }
            }
            if (ShowFeatures)
            {
                if (_vectorSublayerDrawer.isLayerAdded == true)
                {
                    var subLayerArray = property.FindPropertyRelative("vectorSubLayers");
                    var subLayer      = subLayerArray.GetArrayElementAtIndex(subLayerArray.arraySize - 1);
                    ((VectorLayerProperties)EditorHelper.GetTargetObjectOfProperty(property)).OnSubLayerPropertyAdded(new VectorLayerUpdateArgs {
                        property = EditorHelper.GetTargetObjectOfProperty(subLayer) as MapboxDataProperty
                    });
                    _vectorSublayerDrawer.isLayerAdded = false;
                }
            }
        }
        public static Style GetParameters(VectorSourceType defaultElevation)
        {
            Style defaultStyle = new Style();

            switch (defaultElevation)
            {
            case VectorSourceType.MapboxStreets:
                defaultStyle = new Style
                {
                    Id   = "mapbox.mapbox-streets-v7",
                    Name = "Mapbox Streets"
                };

                break;

            case VectorSourceType.MapboxStreetsWithBuildingIds:
                defaultStyle = new Style
                {
                    Id   = "mapbox.3d-buildings,mapbox.mapbox-streets-v7",
                    Name = "Mapbox Streets With Building Ids"
                };

                break;

            case VectorSourceType.Custom:
                throw new Exception("Invalid type : Custom");

            default:
                break;
            }

            return(defaultStyle);
        }
예제 #3
0
        void DrawLayerVisualizerProperties(VectorSourceType sourceType, SerializedProperty layerProperty)
        {
            var subLayerCoreOptions = layerProperty.FindPropertyRelative("coreOptions");

            EditorGUI.indentLevel++;
            GUILayout.Label(subLayerCoreOptions.FindPropertyRelative("sublayerName").stringValue + " Properties");
            GUILayout.BeginVertical();

            VectorPrimitiveType primitiveTypeProp =
                (VectorPrimitiveType)subLayerCoreOptions.FindPropertyRelative("geometryType").enumValueIndex;

            EditorGUILayout.PropertyField(subLayerCoreOptions);

            if (primitiveTypeProp != VectorPrimitiveType.Point && primitiveTypeProp != VectorPrimitiveType.Custom)
            {
                EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("colliderOptions"));

                EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("extrusionOptions"));

                EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("materialOptions"));
            }

            //EditorGUI.indentLevel--;
            ShowOthers = EditorGUILayout.Foldout(ShowOthers, "Advanced");
            EditorGUI.indentLevel++;
            if (ShowOthers)
            {
                if (primitiveTypeProp == VectorPrimitiveType.Polygon && sourceType != VectorSourceType.MapboxStreets)
                {
                    EditorGUI.indentLevel--;
                    layerProperty.FindPropertyRelative("honorBuildingIdSetting").boolValue = true;
                    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. "
                    });
                    EditorGUI.indentLevel++;
                }
                else
                {
                    layerProperty.FindPropertyRelative("honorBuildingIdSetting").boolValue = false;
                }

                EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("filterOptions"), new GUIContent("Filters"));
                DrawModifiers(layerProperty, new GUIContent
                {
                    text    = "Modifier Options",
                    tooltip = "Additional Feature modifiers to apply to the visualizer. "
                });
            }

            EditorGUI.indentLevel--;
            GUILayout.EndVertical();
            EditorGUI.indentLevel--;
        }
예제 #4
0
 private void SetLayerSourceInternal(VectorSourceType vectorSource)
 {
     if (vectorSource != VectorSourceType.Custom && vectorSource != VectorSourceType.None)
     {
         _layerProperty.sourceType = vectorSource;
         _layerProperty.sourceOptions.layerSource = MapboxDefaultVector.GetParameters(vectorSource);
     }
     else
     {
         Debug.LogWarning("Invalid style - trying to set " + vectorSource.ToString() + " as default style!");
     }
 }
        /// <summary>
        /// Gets the tile stats json for the supplied source Id.
        /// </summary>
        /// <returns>A prepopulated <see cref=" TileStats"/> instance.</returns>
        /// <param name="sourceId">Source Id of the Mapbox Tileset.</param>
        public TileStats GetTileStats(VectorSourceType sourceType)
        {
            TileStats stats = null;

            switch (sourceType)
            {
            case VectorSourceType.MapboxStreets:
            case VectorSourceType.MapboxStreetsWithBuildingIds:
                StreamReader reader = new StreamReader(_filePath);
                stats = JsonConvert.DeserializeObject <TileStats>(reader.ReadToEnd());
                reader.Close();
                break;

            default:
                break;
            }
            return(stats);
        }
예제 #6
0
        public void DrawUI(SerializedProperty property)
        {
            objectId = property.serializedObject.targetObject.GetInstanceID().ToString();
            var layerSourceProperty = property.FindPropertyRelative("sourceOptions");
            var sourceTypeProperty  = property.FindPropertyRelative("_sourceType");

            var names = sourceTypeProperty.enumNames;
            VectorSourceType sourceTypeValue = ((VectorSourceType)Enum.Parse(typeof(VectorSourceType), names[sourceTypeProperty.enumValueIndex]));
            //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(_requiredTilesetIdGui, 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);
            }
        }
예제 #7
0
        /// <summary>
        /// Gets the tile stats json for the supplied source Id.
        /// </summary>
        /// <returns>A prepopulated <see cref=" TileStats"/> instance.</returns>
        /// <param name="sourceId">Source Id of the Mapbox Tileset.</param>
        public TileStats GetTileStats(VectorSourceType sourceType)
        {
            TileStats stats = null;

            switch (sourceType)
            {
            case VectorSourceType.MapboxStreets:
            case VectorSourceType.MapboxStreetsWithBuildingIds:
                using (Stream stream = new FileStream(_filePath, FileMode.Open))
                {
                    using (StreamReader reader = new StreamReader(stream))
                    {
                        stats = JsonConvert.DeserializeObject <TileStats>(reader.ReadToEnd());
                    }
                }
                break;

            default:
                break;
            }
            return(stats);
        }
 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;
 }
예제 #9
0
 /// <summary>
 /// Sets the layer source as Style-optimized vector tiles
 /// </summary>
 /// <param name="vectorSource">Vector source.</param>
 /// <param name="styleId">Style-Optimized style id.</param>
 /// <param name="modifiedDate">Modified date.</param>
 /// <param name="styleName">Style name.</param>
 public virtual void SetLayerSourceWithOptimizedStyle(VectorSourceType vectorSource, string styleId, string modifiedDate, string styleName = null)
 {
     SetLayerSourceInternal(vectorSource);
     SetOptimizedStyleInternal(styleId, modifiedDate, styleName);
     _layerProperty.HasChanged = true;
 }
예제 #10
0
 /// <summary>
 /// Change existing data source (TilesetId) with provided source.
 /// </summary>
 /// <param name="vectorSource">Data source (TilesetId) to use.</param>
 public virtual void SetLayerSource(VectorSourceType vectorSource)
 {
     SetLayerSourceInternal(vectorSource);
     _layerProperty.HasChanged = true;
 }
        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);
        }
        void DrawLayerVisualizerProperties(VectorSourceType sourceType, SerializedProperty layerProperty, SerializedProperty property)
        {
            var subLayerCoreOptions = layerProperty.FindPropertyRelative("coreOptions");

            var subLayerName    = subLayerCoreOptions.FindPropertyRelative("sublayerName").stringValue;
            var visualizerLayer = subLayerCoreOptions.FindPropertyRelative("layerName").stringValue;
            var subLayerType    = PresetSubLayerPropertiesFetcher.GetPresetTypeFromLayerName(visualizerLayer);

            GUILayout.Space(-_lineHeight);
            layerProperty.FindPropertyRelative("presetFeatureType").intValue = (int)subLayerType;

            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 ***********************************//

            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--;
        }
예제 #13
0
        public void DrawUI(SerializedProperty layerProperty, VectorPrimitiveType primitiveTypeProp, VectorSourceType sourceType)
        {
            showGameplay = EditorGUILayout.Foldout(showGameplay, "Behavior Modifiers");
            if (showGameplay)
            {
                if (!(primitiveTypeProp != VectorPrimitiveType.Point && primitiveTypeProp != VectorPrimitiveType.Custom))
                {
                    layerProperty.FindPropertyRelative("honorBuildingIdSetting").boolValue = false;
                }


                if ((primitiveTypeProp == VectorPrimitiveType.Polygon || primitiveTypeProp == VectorPrimitiveType.Custom) && sourceType != VectorSourceType.MapboxStreets)
                {
                    layerProperty.FindPropertyRelative("honorBuildingIdSetting").boolValue = true;
                    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. "
                    });
                }

                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]
                        };
                    }

                    featurePositionProperty.enumValueIndex = EditorGUILayout.Popup(dropDownLabel, featurePositionProperty.enumValueIndex, dropDownItems);
                }
                EditorGUILayout.EndHorizontal();
                DrawMeshModifiers(layerProperty);
                DrawGoModifiers(layerProperty);
            }
        }
예제 #14
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            GUILayout.BeginVertical();
            EditorGUILayout.Space();

            ShowGeneral = EditorGUILayout.Foldout(ShowGeneral, new GUIContent {
                text = "GENERAL", tooltip = "Options related to map data"
            });
            if (ShowGeneral)
            {
                EditorGUILayout.Space();
                DrawMapOptions(serializedObject);
            }

            ShowSepartor();

            ShowImage = EditorGUILayout.Foldout(ShowImage, "IMAGE");
            if (ShowImage)
            {
                ShowSection(serializedObject.FindProperty("_imagery"), "_layerProperty");
            }

            ShowSepartor();

            ShowTerrain = EditorGUILayout.Foldout(ShowTerrain, "TERRAIN");
            if (ShowTerrain)
            {
                ShowSection(serializedObject.FindProperty("_terrain"), "_layerProperty");
            }

            ShowSepartor();

            ShowLocationPrefabs = EditorGUILayout.Foldout(ShowLocationPrefabs, "LOCATION PREFABS");
            if (ShowLocationPrefabs)
            {
                var vectorDataProperty = serializedObject.FindProperty("_vectorData");


                var layerProperty                = vectorDataProperty.FindPropertyRelative("_layerProperty");
                var layerSourceProperty          = layerProperty.FindPropertyRelative("sourceOptions");
                var sourceType                   = layerProperty.FindPropertyRelative("_sourceType");
                VectorSourceType sourceTypeValue = (VectorSourceType)sourceType.enumValueIndex;
                string           streets_v7      = MapboxDefaultVector.GetParameters(VectorSourceType.MapboxStreets).Id;
                string           layerString     = layerProperty.FindPropertyRelative("sourceOptions.layerSource.Id").stringValue;

                if (sourceTypeValue != VectorSourceType.None && layerString.Contains(streets_v7))
                {
                    GUI.enabled = false;
                    EditorGUILayout.TextField(_mapIdGui, streets_v7);
                    GUI.enabled = true;
                    ShowSection(vectorDataProperty, "_locationPrefabsLayerProperties");
                }
                else
                {
                    EditorGUILayout.HelpBox("In order to place location prefabs please add \"mapbox.mapbox-streets-v7\" to the data source in the Vector section.", MessageType.Error);
                }
            }

            ShowSepartor();

            ShowVector = EditorGUILayout.Foldout(ShowVector, "VECTOR");
            if (ShowVector)
            {
                ShowSection(serializedObject.FindProperty("_vectorData"), "_layerProperty");
            }
            GUILayout.EndVertical();

            serializedObject.ApplyModifiedProperties();
        }
        void DrawMapLayerOptions()
        {
            var vectorDataProperty           = serializedObject.FindProperty("_vectorData");
            var layerProperty                = vectorDataProperty.FindPropertyRelative("_layerProperty");
            var layerSourceProperty          = layerProperty.FindPropertyRelative("sourceOptions");
            var sourceTypeProperty           = layerProperty.FindPropertyRelative("_sourceType");
            VectorSourceType sourceTypeValue = (VectorSourceType)sourceTypeProperty.enumValueIndex;
            var    layerSourceId             = layerProperty.FindPropertyRelative("sourceOptions.layerSource.Id");
            string layerString               = layerSourceId.stringValue;
            var    isActiveProperty          = layerSourceProperty.FindPropertyRelative("isActive");

            var displayNames = sourceTypeProperty.enumDisplayNames;
            int count        = sourceTypeProperty.enumDisplayNames.Length;

            if (!_isGUIContentSet)
            {
                _sourceTypeContent = new GUIContent[count];
                for (int extIdx = 0; extIdx < count; extIdx++)
                {
                    _sourceTypeContent[extIdx] = new GUIContent
                    {
                        text    = displayNames[extIdx],
                        tooltip = ((VectorSourceType)extIdx).Description(),
                    };
                }

                _isGUIContentSet = true;
            }

            sourceTypeProperty.enumValueIndex = EditorGUILayout.Popup(new GUIContent
            {
                text    = "Data Source",
                tooltip = "Source tileset for Vector Data"
            }, sourceTypeProperty.enumValueIndex, _sourceTypeContent);

            sourceTypeValue = (VectorSourceType)sourceTypeProperty.enumValueIndex;

            switch (sourceTypeValue)
            {
            case VectorSourceType.MapboxStreets:
            case VectorSourceType.MapboxStreetsWithBuildingIds:
                var sourcePropertyValue = MapboxDefaultVector.GetParameters(sourceTypeValue);
                layerSourceId.stringValue = sourcePropertyValue.Id;
                GUI.enabled = false;
                EditorGUILayout.PropertyField(layerSourceProperty, mapIdGui);
                GUI.enabled = true;
                isActiveProperty.boolValue = true;
                break;

            case VectorSourceType.Custom:
                EditorGUILayout.PropertyField(layerSourceProperty, mapIdGui);
                isActiveProperty.boolValue = true;
                break;

            case VectorSourceType.None:
                isActiveProperty.boolValue = false;
                break;

            default:
                isActiveProperty.boolValue = false;
                break;
            }

            if (sourceTypeValue != VectorSourceType.None)
            {
                var isStyleOptimized = layerProperty.FindPropertyRelative("useOptimizedStyle");
                EditorGUILayout.PropertyField(isStyleOptimized);

                if (isStyleOptimized.boolValue)
                {
                    EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("optimizedStyle"), new GUIContent("Style Options"));
                }
                GUILayout.Space(-_lineHeight);
                EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("performanceOptions"), new GUIContent("Perfomance Options"));
            }

            EditorGUILayout.Space();
            ShowSepartor();

            GUILayout.Space(-2.0f * _lineHeight);
            ShowSection(serializedObject.FindProperty("_vectorData"), "_layerProperty");
        }
        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.LayerProperty.tileJsonData;

            var layerDisplayNames = tileJsonData.LayerDisplayNames;

            DrawLayerName(subLayerCoreOptions, layerDisplayNames);
            //*********************** 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--;
        }
예제 #17
0
        void DrawMapLayerOptions()
        {
            var vectorDataProperty           = serializedObject.FindProperty("_vectorData");
            var layerProperty                = vectorDataProperty.FindPropertyRelative("_layerProperty");
            var layerSourceProperty          = layerProperty.FindPropertyRelative("sourceOptions");
            var sourceTypeProperty           = layerProperty.FindPropertyRelative("_sourceType");
            VectorSourceType sourceTypeValue = (VectorSourceType)sourceTypeProperty.enumValueIndex;
            var    layerSourceId             = layerProperty.FindPropertyRelative("sourceOptions.layerSource.Id");
            string layerString               = layerSourceId.stringValue;
            var    isActiveProperty          = layerSourceProperty.FindPropertyRelative("isActive");

            var displayNames = sourceTypeProperty.enumDisplayNames;
            var names        = sourceTypeProperty.enumNames;
            int count        = sourceTypeProperty.enumDisplayNames.Length;

            if (!_isGUIContentSet)
            {
                _sourceTypeContent = new GUIContent[count];

                var index = 0;
                foreach (var name in names)
                {
                    _sourceTypeContent[index] = new GUIContent
                    {
                        text    = displayNames[index],
                        tooltip = ((VectorSourceType)Enum.Parse(typeof(VectorSourceType), name)).Description(),
                    };
                    index++;
                }
                //
                //				for (int extIdx = 0; extIdx < count; extIdx++)
                //				{
                //					_sourceTypeContent[extIdx] = new GUIContent
                //					{
                //						text = displayNames[extIdx],
                //						tooltip = ((VectorSourceType)extIdx).Description(),
                //					};
                //				}

                _isGUIContentSet = true;
            }

            EditorGUI.BeginChangeCheck();
            sourceTypeProperty.enumValueIndex = EditorGUILayout.Popup(new GUIContent
            {
                text    = "Data Source",
                tooltip = "Source tileset for Vector Data"
            }, sourceTypeProperty.enumValueIndex, _sourceTypeContent);

            //sourceTypeValue = (VectorSourceType)sourceTypeProperty.enumValueIndex;
            sourceTypeValue = ((VectorSourceType)Enum.Parse(typeof(VectorSourceType), names[sourceTypeProperty.enumValueIndex]));

            switch (sourceTypeValue)
            {
            case VectorSourceType.MapboxStreets:
            case VectorSourceType.MapboxStreetsV8:
            case VectorSourceType.MapboxStreetsWithBuildingIds:
            case VectorSourceType.MapboxStreetsV8WithBuildingIds:
                var sourcePropertyValue = MapboxDefaultVector.GetParameters(sourceTypeValue);
                layerSourceId.stringValue = sourcePropertyValue.Id;
                GUI.enabled = false;
                EditorGUILayout.PropertyField(layerSourceProperty, mapIdGui);
                GUI.enabled = true;
                isActiveProperty.boolValue = true;
                break;

            case VectorSourceType.Custom:
                EditorGUILayout.PropertyField(layerSourceProperty, mapIdGui);
                isActiveProperty.boolValue = true;
                break;

            case VectorSourceType.None:
                isActiveProperty.boolValue = false;
                break;

            default:
                isActiveProperty.boolValue = false;
                break;
            }

            if (sourceTypeValue != VectorSourceType.None)
            {
                var isStyleOptimized = layerProperty.FindPropertyRelative("useOptimizedStyle");
                EditorGUILayout.PropertyField(isStyleOptimized);

                if (isStyleOptimized.boolValue)
                {
                    EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("optimizedStyle"), new GUIContent("Style Options"));
                }
                GUILayout.Space(-_lineHeight);
                EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("performanceOptions"), new GUIContent("Perfomance Options"));
            }

            EditorGUILayout.Space();
            ShowSepartor();

            _vectorLayerDrawer.DrawUI(layerProperty);

            if (EditorGUI.EndChangeCheck())
            {
                EditorHelper.CheckForModifiedProperty(layerProperty);
            }
        }