Custom inspector ReorderableList gives an error when adding item to list
Hi there, 
 
 So i am creating a database for maps that i can unlock during the game. I have made a custom inspector for the database and i am using a ReorderableList that shows the maps i can unlock. 
 
 In addition, i am using a List to create a foldable list for every ReordarableList. 
 
 I am using onAddCallback to increase the size of List every time i add a new map(new item to the ReorderableList). 
 
 The problem is when i add a new map, the size of the List is increased, than it is decreased and than increased again, and i get an Argument is out of Range error. 
 
 Please see the code and the screenshot attached for more details for more details. 
 
 Thank you in advance!
 // here is the part when i add a new map(new item to the ReorderableList)
 worldMaps.onAddCallback = (ReorderableList l) =>
             {
                 showWorldMapLocalMaps.Add(false);
                 chaptersDatabaseSO.worldMaps.Add(new WorldMaps());
               
             };
 
             worldMaps.DoLayoutList();
 
 
  for (int i = 0; i < chaptersDatabaseSO.worldMaps.Count; i++)
         {
             Debug.Log("i = " + i );
            
             Debug.Log("showWorldMapLocalMaps.Count = " + showWorldMapLocalMaps.Count);
 
 // this is where i get the index out of range error
 showWorldMapLocalMaps[i] = EditorGUILayout.Foldout(showWorldMapLocalMaps[i], " Local Maps");}

Your answer
 
 
             Follow this Question
Related Questions
Custom Inspector List Reset 0 Answers
Updating a List from a Custom Inspector 0 Answers
How can I color a PrefixLabel? 0 Answers
CustomEditor stops displaying after changing script location 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                