- Home /
Question by
Smalltoes · Apr 24, 2019 at 04:00 PM ·
inspectoreditor-scriptingscritping
Unity Inspector Choose C# object from list
Hi,
In my code, I essentially have two classes, ElementType and SubstanceType. Currently, I have some simple code that allows me to create one list of each of these objects through unity's inspector window for the gameobject this class is attached to.
public class SubstanceManager : MonoBehaviour
{
public ElementType[] elementTypes;
public SubstanceType[] substanceTypes;
}
This works well for the elementType, which is a simple class with a couple string fields. In my substanceTypes though, each type references a list of elementTypes like this.
[System.Serializable]
public class SubstanceType
{
[SerializeField]
string _name;
[SerializeField]
ElementType[] _constituents;
}
After writing this though, the inspector wants me to create more ElementTypes for each substance type, but really I would to just be able to select ElementTypes from my previously created list. I Imagine that the custom unity editor tools might allow me to do this, but I'm not sure how.
Thanks you.
Comment