public override void OnInspectorGUI() { LoadPreferences(); TileDataFoldout(); base.OnInspectorGUI(); bool valid = IsValid(); EditorConfig.SetColor(valid ? EditorConfig.DownloadButtonEnabledColor : EditorConfig.DownloadButtonDisabledColor); if (GUILayout.Button("Download")) { if (valid) { LogWarnings(); mapzenMap.DownloadTiles(); } else { LogErrors(); } } EditorConfig.ResetColor(); SavePreferences(); }
private void AddLayerStyleLayout(FeatureStyle.FilterStyle filterStyle, string name) { EditorConfig.SetColor(EditorConfig.AddButtonColor); if (GUILayout.Button(EditorConfig.AddButtonContent, EditorConfig.SmallButtonWidth)) { // Layers within a filter are identifier by their layer name var queryLayer = filterStyle.LayerStyles.Where(layerStyle => name == layerStyle.LayerName); if (name.Length == 0) { Debug.LogError("Layer name can't be empty"); } else if (queryLayer.Count() > 0) { Debug.LogError("A layer with name " + name + " already exists"); } else { var layerStyle = new FeatureStyle.LayerStyle(name); // Default configuration for the layer layerStyle.PolygonBuilderOptions = PolygonBuilderEditor.DefaultOptions(); layerStyle.PolylineBuilderOptions = PolylineBuilderEditor.DefaultOptions(); layerStyle.Material = new Material(Shader.Find("Diffuse")); filterStyle.AddLayerStyle(layerStyle); // Create the associated layer editor layerStyleEditors.Add(new LayerStyleEditor(layerStyle)); } } EditorConfig.ResetColor(); }
public void OnInspectorGUI() { EditorGUILayout.BeginHorizontal(); { filterName = EditorGUILayout.TextField("Filter name: ", filterName); EditorConfig.SetColor(EditorConfig.AddButtonColor); if (GUILayout.Button(EditorConfig.AddButtonContent, EditorConfig.SmallButtonWidth)) { // Filters within a style are identified by their filter name var queryFilterStyleName = style.FilterStyles.Where(filterStyle => filterStyle.Name == filterName); if (filterName.Length == 0) { Debug.LogError("The filter name can't be empty"); } else if (queryFilterStyleName.Count() > 0) { Debug.LogError("Filter with name " + filterName + " already exists"); } else { var filterStyle = new FeatureStyle.FilterStyle(filterName); style.AddFilterStyle(filterStyle); filterStyleEditors.Add(new FilterStyleEditor(filterStyle)); } } EditorConfig.ResetColor(); } EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel++; for (int i = filterStyleEditors.Count - 1; i >= 0; i--) { var editor = filterStyleEditors[i]; var filterStyle = editor.FilterStyle; var state = FoldoutEditor.OnInspectorGUI(editor.GUID.ToString(), filterStyle.Name); if (state.show) { editor.OnInspectorGUI(); } if (state.markedForDeletion) { style.RemoveFilterStyle(filterStyle); // Remove the editor for this filter filterStyleEditors.RemoveAt(i); } } EditorGUI.indentLevel--; }
public static State OnInspectorGUI(string editorIdentifier, string foldoutName) { var state = new State(); state.show = LoadPreferences(editorIdentifier); EditorGUILayout.BeginHorizontal(); { state.show = EditorGUILayout.Foldout(state.show, foldoutName); EditorConfig.SetColor(EditorConfig.RemoveButtonColor); if (GUILayout.Button(EditorConfig.RemoveButtonContent, EditorConfig.SmallButtonWidth)) { state.markedForDeletion = true; } EditorConfig.ResetColor(); } EditorGUILayout.EndHorizontal(); SavePrefences(editorIdentifier, state.show); return(state); }
public override void OnInspectorGUI() { serializedObject.Update(); GUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(serializedObject.FindProperty("ApiKey")); if (GUILayout.Button("Get an API key", EditorStyles.miniButtonRight)) { Application.OpenURL("https://mapzen.com/developers"); } GUILayout.EndHorizontal(); EditorGUILayout.PropertyField(serializedObject.FindProperty("Style"), true); EditorGUILayout.PropertyField(serializedObject.FindProperty("Area"), true); EditorGUILayout.PropertyField(serializedObject.FindProperty("UnitsPerMeter")); EditorGUILayout.PropertyField(serializedObject.FindProperty("RegionName")); map.GroupOptions = (SceneGroupType)EditorGUILayout.EnumMaskPopup("Grouping Options", map.GroupOptions); // EditorGUILayout.PropertyField(serializedObject.FindProperty("GroupOptions")); EditorGUILayout.PropertyField(serializedObject.FindProperty("GameObjectOptions"), true); bool valid = map.IsValid(); EditorConfig.SetColor(valid ? EditorConfig.DownloadButtonEnabledColor : EditorConfig.DownloadButtonDisabledColor); if (GUILayout.Button("Download")) { map.LogWarnings(); if (valid) { map.DownloadTilesAsync(); } else { map.LogErrors(); } } if (map.HasPendingTasks()) { // Go through another OnInspectorGUI cycle Repaint(); if (map.FinishedRunningTasks()) { map.GenerateSceneGraph(); } } EditorConfig.ResetColor(); serializedObject.ApplyModifiedProperties(); }