Question by
Moohead · Dec 30, 2016 at 08:28 AM ·
prefablisteditorguilayout
Trying to add a prefab to a list that i can edit in the inspector. All other items work.
for (int i = 0; i < dwarven.Count; i++)
{
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField(dwarven[i].name);
if (GUILayout.Button("-"))
cm.cardList.Remove(dwarven[i]);
EditorGUILayout.EndHorizontal();
EditorGUI.indentLevel += 1;
dwarven[i].name = EditorGUILayout.TextField("Name: ", dwarven[i].name);
dwarven[i].ID = int.Parse(EditorGUILayout.TextField("ID: ", dwarven[i].ID.ToString()));
dwarven[i].Cost = int.Parse(EditorGUILayout.TextField("Cost: ", dwarven[i].Cost.ToString()));
dwarven[i].cardPrefab = EditorGUILayout.ObjectField("Card Prefab: ", GameObject.cardPrefab, typeof(GameObject));
// i've also tried
//Card.cardPrefab = (GameObject)EditorGUILayout.ObjectField("Card Prefab:", dwarven[i].cardPrefab, typeof(GameObject), true);
EditorGUI.indentLevel -= 1;
EditorGUILayout.Space();
}
if (GUILayout.Button("Add New Card"))
{
Dwarven newDwarven = CreateInstance<Dwarven>();
newDwarven.name = "";
newDwarven.ID = 0;
newDwarven.Cost = 0;
newDwarven.cardPrefab = cardPrefab as GameObject;
cm.cardList.Add(newDwarven);
}
EditorGUI.indentLevel = 0;
Comment