public static void Open(SerializedProperty property) { StyleSearchWindow window = GetWindow <StyleSearchWindow>(true, "Search for style"); window._property = property; window._username = property.FindPropertyRelative("UserName").stringValue; if (!string.IsNullOrEmpty(window._username)) { window.Search(window._username); } Runnable.EnableRunnableInEditor(); Event e = Event.current; Vector2 mousePos = GUIUtility.GUIToScreenPoint(e.mousePosition); window.position = new Rect(mousePos.x - width, mousePos.y, width, height); window.minSize = new Vector2(400, 500); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label); EditorGUILayout.HelpBox("Style Id and Modified date is required for optimized tileset feature. You can copy&paste those values from Styles page under your Mapbox Account or use the search feature to fetch them automatically.", MessageType.Info); EditorGUI.indentLevel++; var id = property.FindPropertyRelative("Id"); var name = property.FindPropertyRelative("Name"); var modified = property.FindPropertyRelative("Modified"); id.stringValue = EditorGUILayout.TextField("Id: ", id.stringValue); name.stringValue = EditorGUILayout.TextField("Name: ", name.stringValue); modified.stringValue = EditorGUILayout.TextField("Modified: ", modified.stringValue); EditorGUILayout.BeginHorizontal(); if (string.IsNullOrEmpty(MapboxAccess.Instance.Configuration.AccessToken)) { GUI.enabled = false; GUILayout.Button("Need Mapbox Access Token"); GUI.enabled = true; } else { if (GUILayout.Button("Search")) { StyleSearchWindow.Open(property); } } if (GUILayout.Button("Clear", GUILayout.Width(100))) { id.stringValue = ""; name.stringValue = ""; modified.stringValue = ""; } EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel--; }