private void ShowAddressOrLatLonUI(SerializedProperty property) { //EditorGUILayout.BeginVertical(); var coordinateProperties = property.FindPropertyRelative("coordinates"); for (int i = 0; i < coordinateProperties.arraySize; i++) { EditorGUILayout.BeginHorizontal(); //get the element to draw var coordinate = coordinateProperties.GetArrayElementAtIndex(i); //label for each location. var coordinateLabel = String.Format("Location {0}", i); // draw coordinate string. EditorGUI.BeginChangeCheck(); coordinate.stringValue = EditorGUILayout.TextField(coordinateLabel, coordinate.stringValue); if (EditorGUI.EndChangeCheck()) { EditorHelper.CheckForModifiedProperty(property, true); } // draw search button. if (GUILayout.Button(new GUIContent(searchButtonContent), (GUIStyle)"minibuttonleft", GUILayout.MaxWidth(100))) { object propertyObject = EditorHelper.GetTargetObjectOfProperty(property); GeocodeAttributeSearchWindow.Open(coordinate, propertyObject); } //include a remove button in the row if (GUILayout.Button(new GUIContent(" X "), (GUIStyle)"minibuttonright", GUILayout.MaxWidth(30))) { coordinateProperties.DeleteArrayElementAtIndex(i); EditorHelper.CheckForModifiedProperty(property); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); GUILayout.Space(EditorGUIUtility.labelWidth - 3); if (GUILayout.Button(new GUIContent("Add Location"), (GUIStyle)"minibutton")) { coordinateProperties.arraySize++; var newElement = coordinateProperties.GetArrayElementAtIndex(coordinateProperties.arraySize - 1); newElement.stringValue = ""; EditorHelper.CheckForModifiedProperty(property); } EditorGUILayout.EndHorizontal(); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { float buttonWidth = EditorGUIUtility.singleLineHeight * 4; Rect fieldRect = new Rect(position.x, position.y, position.width - buttonWidth, EditorGUIUtility.singleLineHeight); Rect buttonRect = new Rect(position.x + position.width - buttonWidth, position.y, buttonWidth, EditorGUIUtility.singleLineHeight); EditorGUI.PropertyField(fieldRect, property); if (GUI.Button(buttonRect, searchButtonContent)) { GeocodeAttributeSearchWindow.Open(property); } }