Example #1
0
        private void FilePopup(GUIContent label, string selectedString, ref string[] names, ref string[] paths, RefString outString, string defaultString, Action onChanged)
        {
            GUIStyle style = EditorStyles.popup;

            GUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel(label, style);

            int[] selected = new int[0];
            if (paths.Contains(selectedString))
            {
                selected = new[] { Array.IndexOf(paths, selectedString) }
            }
            ;
            GUIContent       text = new GUIContent(selected.Length == 0 ? defaultString : names[selected[0]]);
            Rect             r    = GUILayoutUtility.GetRect(GUIContent.none, style);
            AppsListUserData ud   = new AppsListUserData(paths, outString, onChanged);

            if (EditorGUI.DropdownButton(r, text, FocusType.Passive, style))
            {
                ArrayUtility.Add(ref names, Styles.browse.text);
                EditorUtility.DisplayCustomMenu(r, names, selected, AppsListClick, ud, false);
            }
            GUILayout.EndHorizontal();
        }
Example #2
0
 public AppsListUserData(string[] paths, RefString str, Action onChanged)
 {
     this.paths     = paths;
     this.str       = str;
     this.onChanged = onChanged;
 }