Skip to content

Commit ae817a6

Browse files
authored
Fix custom mapid (#666)
* Fix custom mapId being overridden by empty string. * Add missing reference
1 parent f897c97 commit ae817a6

File tree

4 files changed

+44
-4
lines changed

4 files changed

+44
-4
lines changed

sdkproject/Assets/Mapbox/Unity/Editor/GeocodeAttributeSearchWindow.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Collections.Generic;
66
using Mapbox.Geocoding;
77
using Mapbox.Unity;
8+
using System.Globalization;
89

910
public class GeocodeAttributeSearchWindow : EditorWindow
1011
{
@@ -142,4 +143,4 @@ void HandleGeocoderResponse(ForwardGeocodeResponse res)
142143
//}
143144
}
144145
}
145-
}
146+
}

sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/ElevationLayerPropertiesDrawer.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@ bool ShowPosition
3030
tooltip = "Map Id corresponding to the tileset."
3131
};
3232

33+
string CustomSourceMapId
34+
{
35+
get
36+
{
37+
return EditorPrefs.GetString("ElevationLayerProperties_customSourceMapId");
38+
}
39+
set
40+
{
41+
EditorPrefs.SetString("ElevationLayerProperties_customSourceMapId", value);
42+
}
43+
}
44+
3345
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
3446
{
3547
EditorGUI.BeginProperty(position, label, property);
@@ -73,8 +85,9 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
7385
GUI.enabled = true;
7486
break;
7587
case ElevationSourceType.Custom:
76-
layerSourceId.stringValue = string.Empty;
88+
layerSourceId.stringValue = CustomSourceMapId;
7789
EditorGUI.PropertyField(position, sourceOptionsProperty, _mapIdGui);
90+
CustomSourceMapId = layerSourceId.stringValue;
7891
break;
7992
default:
8093
break;

sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/ImageryLayerPropertiesDrawer.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@ public class ImageryLayerPropertiesDrawer : PropertyDrawer
1919
tooltip = "Map Id corresponding to the tileset."
2020
};
2121

22+
string CustomSourceMapId
23+
{
24+
get
25+
{
26+
return EditorPrefs.GetString("ImageryLayerProperties_customSourceMapId");
27+
}
28+
set
29+
{
30+
EditorPrefs.SetString("ImageryLayerProperties_customSourceMapId", value);
31+
}
32+
}
33+
2234
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
2335
{
2436
EditorGUI.BeginProperty(position, label, property);
@@ -69,8 +81,9 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
6981
GUI.enabled = true;
7082
break;
7183
case ImagerySourceType.Custom:
72-
layerSourceId.stringValue = string.Empty;
84+
layerSourceId.stringValue = CustomSourceMapId;
7385
EditorGUI.PropertyField(position, sourceOptionsProperty, new GUIContent{text = "Map Id / Style URL", tooltip = _mapIdGui.tooltip} );
86+
CustomSourceMapId = layerSourceId.stringValue;
7487
break;
7588
case ImagerySourceType.None:
7689
break;

sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,18 @@ int SelectionIndex
5454
}
5555
}
5656

57+
string CustomSourceMapId
58+
{
59+
get
60+
{
61+
return EditorPrefs.GetString("VectorLayerProperties_customSourceMapId");
62+
}
63+
set
64+
{
65+
EditorPrefs.SetString("VectorLayerProperties_customSourceMapId", value);
66+
}
67+
}
68+
5769
private GUIContent _mapIdGui = new GUIContent
5870
{
5971
text = "Map Id",
@@ -108,8 +120,9 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
108120
isActiveProperty.boolValue = true;
109121
break;
110122
case VectorSourceType.Custom:
111-
layerSourceId.stringValue = string.Empty;
123+
layerSourceId.stringValue = CustomSourceMapId;
112124
EditorGUILayout.PropertyField(sourceOptionsProperty, _mapIdGui);
125+
CustomSourceMapId = layerSourceId.stringValue;
113126
isActiveProperty.boolValue = true;
114127
break;
115128
case VectorSourceType.None:

0 commit comments

Comments
 (0)