Generic List In Custom Editor Window

Hi:

I am trying to make a custom editor window with a grneric list. the same as one in the inspector when you attach it on a gameobject.

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 using UnityEditor;
 
 [System.Serializable]
 public class Tile
 {
     public GameObject tile; //the tile prefab
     public Color tileColor; //the reffrence of color to instantiate prefab
 }
 
 
 public class LevelGenerator : EditorWindow
 {
 
     public List<Tile> tileList;
 
     [MenuItem("Window/My Editor/Level Generator")]
     public static void ShowWindow()
     {
         GetWindow<LevelGenerator>("Level Generator");
     }
 
     //window code
     void OnGUI()
     {
         tileList = EditorGUILayout.List<Tile>("Tile", tileList); //Having trouble with this part!!!
     }
 }

I am thinking it has to do with “propertyfields” but having trouble implementing it.

Thanks: James

I got this to work with placing this part of code in the area where i wanted the list to show up in the editor.

        //to show the list of tiles//
        ScriptableObject target = this;
        SerializedObject so = new SerializedObject(target);
        SerializedProperty stringsProperty = so.FindProperty("tileList");

        EditorGUILayout.PropertyField(stringsProperty, true);
        so.ApplyModifiedProperties();
        //end for the list of tiles

@jimjames Thanks for this as i am now able to see my list in the custom editor, the problem i am having is that the list is not editable from the editor, it is grayed out. Did you have this issue and do you have any solutions?
160373-capture.png

I have been searching for a solution for this here in 2022

And I just replaced “tileList” with the name of myList
Thank you, Thank you!