コード例 #1
0
 private void AppsListClick(object userData, string[] options, int selected)
 {
     PreferencesWindow.AppsListUserData appsListUserData = (PreferencesWindow.AppsListUserData)userData;
     if (options[selected] == "Browse...")
     {
         string text = EditorUtility.OpenFilePanel("Browse for application", string.Empty, (Application.platform != RuntimePlatform.OSXEditor) ? "exe" : "app");
         if (text.Length != 0)
         {
             appsListUserData.str.str = text;
             if (appsListUserData.onChanged != null)
             {
                 appsListUserData.onChanged();
             }
         }
     }
     else
     {
         appsListUserData.str.str = appsListUserData.paths[selected];
         if (appsListUserData.onChanged != null)
         {
             appsListUserData.onChanged();
         }
     }
     this.WritePreferences();
     this.ReadPreferences();
 }
コード例 #2
0
        private void FilePopup(string label, string selectedString, ref string[] names, ref string[] paths, PreferencesWindow.RefString outString, Action onChanged)
        {
            GUIStyle popup = EditorStyles.popup;

            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            EditorGUILayout.PrefixLabel(label, popup);
            int[] array = new int[]
            {
                Array.IndexOf <string>(paths, selectedString)
            };
            GUIContent content = new GUIContent(names[array[0]]);
            Rect       rect    = GUILayoutUtility.GetRect(GUIContent.none, popup);

            PreferencesWindow.AppsListUserData userData = new PreferencesWindow.AppsListUserData(paths, outString, onChanged);
            if (EditorGUI.ButtonMouseDown(rect, content, FocusType.Native, popup))
            {
                ArrayUtility.Add <string>(ref names, "Browse...");
                EditorUtility.DisplayCustomMenu(rect, names, array, new EditorUtility.SelectMenuItemFunction(this.AppsListClick), userData);
            }
            GUILayout.EndHorizontal();
        }