示例#1
0
        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);
            }
        }
示例#2
0
 /// <summary>
 /// Change the primtive type of the feature which will be used to decide
 /// what type of mesh operations features will require.
 /// In example, roads are generally visualized as lines and buildings are
 /// generally visualized as polygons.
 /// </summary>
 /// <param name="type">Primitive type of the featues in the layer.</param>
 public virtual void SetPrimitiveType(VectorPrimitiveType type)
 {
     if (geometryType != type)
     {
         geometryType = type;
         HasChanged   = true;
     }
 }
示例#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--;
        }
        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--;
        }
        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--;
        }
        /// <summary>
        /// Gets the default sub layer properties for the chosen preset type.
        /// </summary>
        /// <returns>The sub layer properties.</returns>
        /// <param name="type">Type.</param>
        public static VectorSubLayerProperties GetSubLayerProperties(PresetFeatureType type)
        {
            //CoreOptions properties
            VectorPrimitiveType geometryType = VectorPrimitiveType.Polygon;
            string layerName    = "building";
            string sublayerName = "Untitled";

            //Line Geometry Options
            float lineWidth = 1.0f;

            //Geometry Extrusion Options
            ExtrusionType         extrusionType         = ExtrusionType.None;
            ExtrusionGeometryType extrusionGeometryType = ExtrusionGeometryType.RoofAndSide;
            string propertyName         = "height";
            float  extrusionScaleFactor = 1.0f;
            float  extrusionHeight      = 1.0f;

            //Filter Options
            LayerFilterCombinerOperationType combinerType = LayerFilterCombinerOperationType.Any;
            List <LayerFilter> filters = new List <LayerFilter>();


            // Material Options
            StyleTypes style = StyleTypes.Realistic;

            //Misc options
            bool buildingsWithUniqueIds           = true;
            PositionTargetType positionTargetType = PositionTargetType.TileCenter;

            //Modifiers
            List <MeshModifier>       meshModifiers       = new List <MeshModifier>();
            List <GameObjectModifier> gameObjectModifiers = new List <GameObjectModifier>();
            ColliderType colliderType = ColliderType.None;

            switch (type)
            {
            case PresetFeatureType.Buildings:
                layerName             = "building";
                geometryType          = VectorPrimitiveType.Polygon;
                extrusionType         = ExtrusionType.PropertyHeight;
                extrusionGeometryType = ExtrusionGeometryType.RoofAndSide;
                propertyName          = "height";
                style = StyleTypes.Realistic;
                break;

            case PresetFeatureType.Roads:
                layerName             = "road";
                geometryType          = VectorPrimitiveType.Line;
                lineWidth             = 1.0f;
                style                 = StyleTypes.Dark;
                extrusionType         = ExtrusionType.AbsoluteHeight;
                extrusionGeometryType = ExtrusionGeometryType.RoofAndSide;
                break;

            case PresetFeatureType.Points:
                layerName    = "poi_label";
                geometryType = VectorPrimitiveType.Point;
                break;

            case PresetFeatureType.Landuse:
                layerName    = "landuse";
                geometryType = VectorPrimitiveType.Polygon;
                style        = StyleTypes.Color;
                break;

            case PresetFeatureType.Custom:
                layerName    = "";
                geometryType = VectorPrimitiveType.Custom;
                style        = StyleTypes.Custom;
                break;

            default:
                break;
            }

            VectorSubLayerProperties _properties = new VectorSubLayerProperties();

            _properties.presetFeatureType = type;

            _properties.coreOptions = new CoreVectorLayerProperties
            {
                isActive      = true,
                layerName     = layerName,
                geometryType  = geometryType,
                snapToTerrain = true,
                combineMeshes = false,
                sublayerName  = sublayerName
            };

            _properties.lineGeometryOptions = new LineGeometryOptions
            {
                Width = lineWidth
            };

            _properties.extrusionOptions = new GeometryExtrusionOptions
            {
                extrusionType         = extrusionType,
                extrusionGeometryType = extrusionGeometryType,
                propertyName          = propertyName,
                extrusionScaleFactor  = extrusionScaleFactor,
                maximumHeight         = extrusionHeight
            };

            _properties.filterOptions = new VectorFilterOptions
            {
                combinerType = combinerType,
                filters      = filters
            };

            _properties.materialOptions = new GeometryMaterialOptions
            {
                style           = style,
                colorStyleColor = Constants.GUI.Colors.EDITOR_FEATURE_DEFAULT_COLOR
            };
            _properties.materialOptions.SetDefaultMaterialOptions();
            _properties.buildingsWithUniqueIds = buildingsWithUniqueIds;
            _properties.moveFeaturePositionTo  = positionTargetType;
            _properties.MeshModifiers          = meshModifiers;
            _properties.GoModifiers            = gameObjectModifiers;
            _properties.colliderOptions        = new ColliderOptions
            {
                colliderType = colliderType
            };

            return(_properties);
        }
        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();
        }