-
Notifications
You must be signed in to change notification settings - Fork 225
Ui formatting cleanup #738
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7e6dd65
basic cosmetic changes in
apavani f940aee
ui issue fixed
apavani 2070520
duplicate layers taken care of
apavani 613c9ac
fixed indentation issues and checkboxes
apavani f467a2c
added the new UI to the common area
apavani 549f1e2
cosmetic changes done
apavani 110476c
Switch to EditorGuiLayout and some UI formatting changes.
abhishektrip 23d58eb
Merge commit '7924e699988850c0d8bfd621dd2b387b85ad987d' into ui-forma…
abhishektrip File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,7 +103,6 @@ bool ShowFeatures | |
} | ||
} | ||
|
||
|
||
bool ShowPosition | ||
{ | ||
get | ||
|
@@ -136,25 +135,26 @@ string CustomSourceMapId | |
|
||
bool _isGUIContentSet = false; | ||
GUIContent[] _sourceTypeContent; | ||
static float _lineHeight = EditorGUIUtility.singleLineHeight; | ||
|
||
public override void OnInspectorGUI() | ||
{ | ||
serializedObject.Update(); | ||
GUILayout.BeginVertical(); | ||
EditorGUILayout.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) | ||
{ | ||
GUILayout.Space(-1.5f * _lineHeight); | ||
ShowSection(serializedObject.FindProperty("_imagery"), "_layerProperty"); | ||
} | ||
|
||
|
@@ -163,6 +163,7 @@ public override void OnInspectorGUI() | |
ShowTerrain = EditorGUILayout.Foldout(ShowTerrain, "TERRAIN"); | ||
if (ShowTerrain) | ||
{ | ||
GUILayout.Space(-1.5f * _lineHeight); | ||
ShowSection(serializedObject.FindProperty("_terrain"), "_layerProperty"); | ||
} | ||
|
||
|
@@ -171,104 +172,7 @@ public override void OnInspectorGUI() | |
ShowMapLayers = EditorGUILayout.Foldout(ShowMapLayers, "MAP LAYERS"); | ||
if (ShowMapLayers) | ||
{ | ||
EditorGUI.indentLevel++; | ||
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; | ||
string streets_v7 = MapboxDefaultVector.GetParameters(VectorSourceType.MapboxStreets).Id; | ||
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: | ||
layerSourceId.stringValue = CustomSourceMapId; | ||
EditorGUILayout.PropertyField(layerSourceProperty, mapIdGui); | ||
CustomSourceMapId = layerSourceId.stringValue; | ||
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")); | ||
} | ||
|
||
EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("performanceOptions"), new GUIContent("Perfomance Options")); | ||
} | ||
EditorGUILayout.Space(); | ||
ShowSepartor(); | ||
|
||
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; | ||
ShowSection(vectorDataProperty, "_locationPrefabsLayerProperties"); | ||
} | ||
else | ||
{ | ||
EditorGUILayout.HelpBox("In order to place location prefabs please add \"mapbox.mapbox-streets-v7\" to the data source.", MessageType.Error); | ||
} | ||
} | ||
ShowSepartor(); | ||
ShowFeatures = EditorGUILayout.Foldout(ShowFeatures, "FEATURES"); | ||
if (ShowFeatures) | ||
{ | ||
ShowSection(serializedObject.FindProperty("_vectorData"), "_layerProperty"); | ||
} | ||
EditorGUI.indentLevel--; | ||
DrawMapLayerOptions(); | ||
} | ||
GUILayout.EndVertical(); | ||
|
||
|
@@ -291,19 +195,22 @@ void DrawMapOptions(SerializedObject mapObject) | |
{ | ||
var property = mapObject.FindProperty("_options"); | ||
|
||
EditorGUILayout.LabelField("Location "); | ||
EditorGUILayout.LabelField("Location ", GUILayout.Height(_lineHeight)); | ||
|
||
EditorGUILayout.PropertyField(property.FindPropertyRelative("locationOptions")); | ||
var extentOptions = property.FindPropertyRelative("extentOptions"); | ||
var extentOptionsType = extentOptions.FindPropertyRelative("extentType"); | ||
if ((MapExtentType)extentOptionsType.enumValueIndex == MapExtentType.Custom) | ||
{ | ||
|
||
var test = mapObject.FindProperty("_tileProvider"); | ||
EditorGUILayout.PropertyField(extentOptionsType); | ||
EditorGUI.indentLevel++; | ||
EditorGUILayout.PropertyField(test); | ||
EditorGUI.indentLevel--; | ||
} | ||
else | ||
{ | ||
GUILayout.Space(-_lineHeight); | ||
EditorGUILayout.PropertyField(property.FindPropertyRelative("extentOptions")); | ||
} | ||
|
||
|
@@ -312,12 +219,116 @@ void DrawMapOptions(SerializedObject mapObject) | |
ShowPosition = EditorGUILayout.Foldout(ShowPosition, "Others"); | ||
if (ShowPosition) | ||
{ | ||
GUILayout.Space(-_lineHeight); | ||
EditorGUILayout.PropertyField(property.FindPropertyRelative("placementOptions")); | ||
GUILayout.Space(-_lineHeight); | ||
EditorGUILayout.PropertyField(property.FindPropertyRelative("scalingOptions")); | ||
EditorGUILayout.PropertyField(property.FindPropertyRelative("loadingTexture")); | ||
} | ||
} | ||
|
||
void DrawMapLayerOptions() | ||
{ | ||
//EditorGUI.indentLevel++; | ||
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; | ||
string streets_v7 = MapboxDefaultVector.GetParameters(VectorSourceType.MapboxStreets).Id; | ||
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: | ||
layerSourceId.stringValue = CustomSourceMapId; | ||
EditorGUILayout.PropertyField(layerSourceProperty, mapIdGui); | ||
CustomSourceMapId = layerSourceId.stringValue; | ||
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(); | ||
|
||
ShowLocationPrefabs = EditorGUILayout.Foldout(ShowLocationPrefabs, "POINTS OF INTEREST"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be great to rename the underlying classes along with the foldout title. |
||
if (ShowLocationPrefabs) | ||
{ | ||
if (sourceTypeValue != VectorSourceType.None && layerString.Contains(streets_v7)) | ||
{ | ||
GUI.enabled = false; | ||
EditorGUILayout.TextField(_requiredMapIdGui, 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 FEATURES section.", MessageType.Error); | ||
} | ||
} | ||
|
||
ShowSepartor(); | ||
ShowFeatures = EditorGUILayout.Foldout(ShowFeatures, "FEATURES"); | ||
if (ShowFeatures) | ||
{ | ||
ShowSection(serializedObject.FindProperty("_vectorData"), "_layerProperty"); | ||
} | ||
} | ||
|
||
void PresetLocationBased(SerializedProperty unifiedMap) | ||
{ | ||
//Set | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the rationale for the
extIdx
variable name that appears in all of these loops?