How can I find the class I created by inheriting from the inherited class?

Hello. I tried to make a Survival game but I am very confused. now let’s say I have an inventory system. In this InventorySystem there is a List Value that holds ItemClasses. When I use the Use(ItemClass UsingItemClass) function, I give the UsingItemClass value and this value I give is MagazineClass inherited from an ItemClass. now inside this Use function there is code that finds a class inherited from the ItemController class. let’s say it found MagazineController and used the Intialize(ItemClass Item) function inside MagazineController.

Let the Intialize Function be something like this:

 public override void Initialize(ItemClass itemClass)
    {
        Debug.Log("Item Class: " + itemClass.ItemID);
        magazineClass = itemClass as MagazineClass; // Convert to MagazineClass
        Debug.Log("Magazine Class: " + magazineClass);
        base.Initialize(itemClass);

        ...............................................
    }

But this function “Debug.Log(”Item Class: “ + itemClass.ItemID);” returns something but “Debug.Log(”Magazine Class: “ + magazineClass);” returns null. Why?

How can I access MagazineClass from ItemClass?

Without the actual code is very difficult to understand what you have done. The code is the only true description, everything else is hard and generic so I will answer based on the code you have provided.

When you write magazineClass = itemClass as MagazineClass; will perform the conversion only if it is possible else it will return null. In you case if the itemClass is of type MagazineClass the conversion will succeed. If you get null, it means that the itemClass is an instance of a type that either inherits from ItemClass but is not MagazineClass type, or is an instance of the basic ItemClass type.

rebooting unity fixed it, thanks for your help.