Question by
RemDust · Jan 16, 2017 at 04:24 PM ·
scripting probleminheritancesubclass
Check if script is a particular Class
Hi ! I have a baseclass BaseItem (which derived from ScriptableObject) and subclasses (Item, Weapon, Equip etc) All of the objects are stored in a list.
How can I check if a specific element in that list is an item, a weapon ?
Comment
Best Answer
Answer by UnityCoach · Jan 16, 2017 at 04:29 PM
You can use GetType () like :
(item.GetType() == typeof (Weapon)) // return true if weapon