title: EditorGUILayout Popup not accepting changes after drop down choice changes
body: <p>I'm trying to create a custom editor with a list of extension file types that will allow the user to select which "Folder" to be put in. The problem I'm having is that the selected index of the popups (I have an array of them based on the number of extensions that need to be moved) doesn't change and remains in the last position.</p>
  
  <p><a href="https://i.stack.imgur.com/RSVhp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RSVhp.png" alt="enter image description here"></a></p>
  
  <pre><code>public class ExtensionWindow : EditorWindow
  {
      ExtensionBank extBank;
  
      string[] exts;
      public bool[] extToggles;
  
      public static List&lt;string&gt; extensions;
      public static List&lt;string&gt; categories;
  
      public static Vector2 scrollPosition;
  
      [MenuItem("Build Master's Dream  / Organize Files")]
      static void Organize()
      {
          ExtensionWindow myWindow = (ExtensionWindow)EditorWindow.GetWindow(typeof(ExtensionWindow), true, "Extensions");
          myWindow.minSize = new Vector2(300.0f, 300.0f);
          myWindow.maxSize = new Vector2(300.0f, 300.0f);
      }
  
      void Awake()
      {
          //Get all Category names and store them in a List&lt;&gt;
          LoadFolderNames();
          LoadFolders();
  
          extBank = new ExtensionBank();
  
          //Populate the bank of Extensions from the .txt file
          bool success;
          success = extBank.PopulateList();
  
          exts = new string[extBank.GetNumOfExtensions];
  
          if (success)
          {
              for (int i = 0; i &lt; extBank.GetNumOfExtensions; i++)
                  string shortExtensions = extBank.GetExtensions(i);
          }
      }
  
      void OnGUI()
      {
          //extToggles = new bool[extBank.GetNumOfExtensions];
  
          int[] index = new int[extBank.GetNumOfExtensions];
          int selectedIndex = 0;
  
          GUILayout.BeginArea(new Rect(0, 0, 300, 300));
          EditorGUILayout.BeginVertical();
          scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);
  
          for (int i = 0; i &lt; index.Length; i++)
          {
              index[i] = EditorGUILayout.Popup(extBank.GetExtensions(i), index[i], categories.ToArray(), GUILayout.Width(275));
             EditorGUILayout.Space();
          }
          if (GUILayout.Button("Make Your Dream Come True", EditorStyles.miniButtonLeft))
          {
              string[] shortCategories = categories.ToArray();
  
              AssetDatabase.Refresh();
          }
          EditorGUILayout.EndScrollView();
          EditorGUILayout.EndVertical();
          GUILayout.EndArea();
      }
  
      void LoadFolders()
      {
          foreach (string cat in categories)
          {
              string projectPath = Application.dataPath + "/";
              if (cat != "Select Category") ;
              {
                  Directory.CreateDirectory(projectPath + cat);
              }
          }
          AssetDatabase.Refresh();
      }
  
      void BeginMoveOperation(string ext, string cat)
      {
          Debug.Log("Data path is: " + Application.dataPath.ToString());
  
          string localPath = Application.dataPath;
  
          DirectoryInfo dir = new DirectoryInfo(localPath);
          FileInfo[] info = dir.GetFiles("*.*");
          foreach (FileInfo f in info)
          {
              Debug.Log("Name is: " + f.Name);
              Debug.Log("Extension is: " + f.Extension);
              MoveAssetsIntoFolders(f.Name, f.Extension, f.FullName);
          }
      }
  
      static void MoveAssetsIntoFolders(string fileName, string extension, string oldPath)
      {
  
      }
  
      void LoadFolderNames()
      {
          var path = "Assets/Scripts/Editor/Extensions.txt";
  
          if (File.Exists(path))
          {
              try
              {
                  var fileContent = File.ReadAllLines(path);
                  categories = new List&lt;string&gt;();
                  foreach (var line in fileContent)
                  {
                      if (line != "")
                      {
                          if ((line.Substring(0, 1) != "" || line.Substring(0, 1) != null) &amp;&amp; line.Substring(0, 1) != ".")
                          {
                              categories.Add(line);
                          }
                      }
                  }
              }
              catch (Exception ex)
              {
                  Debug.Log(ex);
              }
          }
      }
      void OrganizeScripts()                  
      {
          Assembly _assembly = Assembly.Load("Assembly-CSharp");
  
          foreach (Type type in _assembly.GetTypes())
          {
              if (type.IsClass)
              {
                  if (type.BaseType.FullName.Contains("MonoBehaviour"))           //Standard Unity Scripts
                  {
  
                  }
                  else if (type.BaseType.FullName.Contains("Editor"))             //Unity Editor Files
                  {
  
                  }
              else                                                            //All others, likely .js scripts
                  {
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/oGXJT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oGXJT.png" alt="Screen grab of Code errors"></a></p>