- Home /
Modifying Lists via the inspector
Serialized Lists<> seem to be displayed inconsistently in the inspector. In some cases, I have +/- buttons to add/remove elements, and the elements can be dragged to reorder:
In others, I get neither of these:
In both cases, the fields are Lists of ScriptableObjects, albeit different SO's. Any idea what determines how Lists are displayed in the inspector? The former is far more convenient, so it would be nice to always get that version.
Also (and possibly relatedly?), any idea why the second script above would be toggleable (has a checkmark), while the first isn't?
Mind posting your chunk data / resource data code? There might be some clues in there :)
ChunkManager.cs:
public class ChunkManager : MonoBehaviour {
public bool allowRotation = false;
[SerializeField] private List<ChunkData> chunkDatas = null;
private Dictionary<int, List<ChunkData>> chunkDatasByCount;
...
Faction.cs:
public abstract class Faction : MonoBehaviour {
// Inspector inputs.
public Counter counterPrefab;
[Tooltip("Prefab for the non-UI resource meter")]
public ResourceStore meterPrefab;
[SerializeField] private List<BuildingData> buildingDatas = null;
[SerializeField] private List<ResourceData> resourceDatas = null;
...
PlayerFaction.cs:
public class PlayerFaction : Faction {
...
Also, https://issuetracker.unity3d.com/issues/arrays-are-not-reorderable-by-default-when-serializefield-or-serializereference-attributes-are-used seems to be the same issue, and it looks like this was resolved in 2020.2.0b4. I'm running 2020.2.1f1. Would the latter contain any fixes live in the former?
I think it's an issue with the ChunkData file that one has no script toggle and is displaying weird :P You should include all the code for it in your original post.
The toggle next to the script name has nothing to do with the lists. A component can be enabled or disabled (checkbox visible) only if it implements several functions like Start
, Update
, FixedUpdate
and few other functions.