Question by
haruna9x · May 29, 2017 at 02:55 AM ·
c#inspectorparent-child
Public variables in parent no show in child class
I want to see if the item in the slots works correctly when I drag and drop it. I also tried [SerializeField] but it does not work. I'm beginner with unity. Any answer.
[System.Serializable] public class Container where T : Item { #region Constants and Fields
public struct Slot
{
/// <summary>
/// Gets or sets the item
/// </summary>
public T Item;
/// <summary>
/// Determines whether the slot is empty or not
/// </summary>
public bool IsEmpty
{
get {return this.Item == null;}
}
}
private const int START_SIZE = 20;
private const int MAX_SIZE = 50;
/// <summary>
/// the slots
/// </summary>
public Slot[] slots;
}
[System.Serializable]
public class ItemEquipmentInventory : MonoBehaviour
{
public ItemEquipmentDatabaseList itemEquipmentDatabase;
public const string FOLDER = "Database/";
public const string NAME_ITEM_EQUIPMENT_DATABASE = "ItemEquipmentDatabase";
public Container<ItemEquipment> itemEquipmentContainer;
}
I would like to add a little that itemEquipmentContainer has no show in the inspector for any reason.
Comment
Best Answer
Answer by Sergio7888 · May 29, 2017 at 07:33 PM
With exception of List no generic class is serialized by Unity, and for this reason it can't be show in Inspector, you need create a new non-generic class empty class that extends Container<ItemEquipment>
[System.Serializable]
public class ItemEquipmentContainer : Container<ItemEquipment>{
}
And use
public ItemEquipmentContainer itemEquipmentContainer;
Your answer
![](https://koobas.hobune.stream/wayback/20220612123016im_/https://answers.unity.com/themes/thub/images/avi.jpg)