unity doesn't recognize the derived class

I have a weapon class which derives from the item class and a gun class which derives from the weapon class. when i try to set an item property in the editor and give it a gun it just reads it as a weapon.
but when i give it a sword it reads it perfectly fine. sword class derives from weapon class as well.



Well we don’t know much about what your Item class actually looks like. Since it can be referenced in the inspector it has to be a ScriptableObject or MonoBehaviour derived class. Where are the actual instances that you reference here stored? If they are scriptable objects you probably created standalone assets in your project? If they are actually MonoBehaviour derived classes your gun and sword class has to be attached to an actual gameobject. That gameobject can be either part of the scene or part of a prefab in your project. If it’s a gameobject / prefab, are you sure that you don’t have any other Item derived components attached to the same object? The inspector will simply grab the first matching component when you drag the gameobject onto that field.

A little bit more background would help. Also what exactly is the issue here? Do you have problems with some particular code where you want to access your “item”? If so it would help to see that code snippet that throws an error. If you don’t have a concrete error I’m not sure what you actually expect as answer -.-

my bad i just realized i had an weapon script attached to the gun silly me.

I usually use type object pattern for this over inheritance.

but you should post your code and maybe I will spot someting…