Just add using System.Collections.Generic; under the line using System.Collections;
Also for it to show up in the inspector you will need to add
[System.Serializable]
public class CollideableObject : MonoBehaviour
{
//etc…
The Serializable tag tell Unity to display it’s public variables in the Inspector
3rd. You will need Unity3, as I do believe there are issues with displaying Lists within the Inspector (I thought 2.6 only supported Arrays, though I could be wrong).
@The OP: You can just replace the ‘using System.Collections;’ line if it’s not needed.
My understanding is that List serialization is supported in 2.6. I’m pretty sure I’ve serialized lists with no problems, and edited them in the inspector as well. (Anyway, the OP can at least try it and see if it works.)
Hey guys, I did both but it doesn’t show the public variables of CollidableObject in the inspector. Just a 1 level deep list in which you can select CollidableObject’s and not the public variables inside of them. Is that another question?
I fixed it! By creating the CollidableObject class inside the class where I try to create the list, I get the following structure:
using System.Collections.Generic;
public class ObjectsManager : MonoBehaviour {
[System.Serializable]
public class CollidableObject{
public GameObject objectPrefab;
public int laneSize;
}
public List<CollidableObject> collidableObjects = new List<CollidableObject> ();
//etc
public class Actors : MonoBehaviour {
[System.Serializable]
public class Actor
{
[XmlAttribute("id")]
public int Id { get; set; }
[XmlAttribute("name")]
public string Name { get; set; }
[XmlAttribute("age")]
public int Age { get; set;}
[XmlAttribute("focus")]
public string Focus { get; set;}
[XmlAttribute("skill")]
public int Skill { get; set;}
}
public List<Actor> actors = new List<Actor>();
Sorry for the necroposting. After some searching for whoever is out there I found that you can do it with a PropertyDrawer.
Here is an example:
public class Actors : MonoBehaviour {
[System.Serializable]
public class Actor : PropertyDrawer
{
[XmlAttribute("id")]
public int Id { get; set; }
[XmlAttribute("name")]
public string Name { get; set; }
[XmlAttribute("age")]
public int Age { get; set;}
[XmlAttribute("focus")]
public string Focus { get; set;}
[XmlAttribute("skill")]
public int Skill { get; set;}
}
public List<Actor> actors = new List<Actor>();
By making the Actor inherit from the PropertyDrawer now you can create a List with multiple customizable parameters on it